idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
10,500
protected function initializeCustomerAddress ( array $ attr ) { if ( $ entity = $ this -> loadCustomerAddress ( $ attr [ MemberNames :: ENTITY_ID ] ) ) { return $ this -> mergeEntity ( $ entity , $ attr ) ; } unset ( $ attr [ MemberNames :: ENTITY_ID ] ) ; return $ attr ; }
Initialize the customer address with the passed attributes and returns an instance .
10,501
public function releaseHandle ( ) { if ( is_resource ( $ this -> handle ) ) { fclose ( $ this -> handle ) ; } $ this -> handle = null ; }
Close the handle if opened .
10,502
private function getIdsFiltered ( $ varValue , $ strOperation ) { $ strSql = \ sprintf ( 'SELECT id FROM %s WHERE %s %s %f' , $ this -> getMetaModel ( ) -> getTableName ( ) , $ this -> getColName ( ) , $ strOperation , ( float ) $ varValue ) ; $ statement = $ this -> connection -> query ( $ strSql ) ; return $ statemen...
Filter all values by specified operation .
10,503
public function set ( $ id , $ item ) { $ this -> checkType ( $ item ) ; $ this -> items [ $ id ] = $ item ; return $ this ; }
Set an item for an id
10,504
public function remove ( $ id ) { $ item = $ this -> getOrFail ( $ id ) ; unset ( $ this -> items [ $ id ] ) ; return $ item ; }
Remove item with the passed id
10,505
public function setClass ( $ id , $ class ) { $ this -> classes [ $ id ] = $ class ; if ( isset ( $ this -> items [ $ id ] ) ) { unset ( $ this -> items [ $ id ] ) ; } $ this -> allCreated = false ; return $ this ; }
Set a class for an item for deferred loading of items .
10,506
protected function createAllIfNotDone ( ) { if ( $ this -> allCreated ) { return ; } foreach ( $ this -> classes as $ id => $ class ) { if ( ! isset ( $ this -> items [ $ id ] ) ) { $ this -> get ( $ id ) ; } } $ this -> allCreated = true ; }
Create all objects of all assigned classes
10,507
public function authenticate ( FilterUserResponseEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { try { $ this -> loginManager -> logInUser ( $ this -> firewallName , $ event -> getUser ( ) , $ event -> getResponse ( ) ) ; $ dispatcher -> dispatch ( Events :: SECURITY_IMPLICIT_LOGIN , new UserEve...
Authenticates the user .
10,508
protected function changePaymentTypeInCode ( $ paymentCode , $ paymentType ) { $ parts = explode ( '.' , $ paymentCode ) ; $ paymentMethod = reset ( $ parts ) ; return $ paymentMethod . '.' . $ paymentType ; }
Changes payment type part in payment code
10,509
public function forEntity ( $ entityClass , DataMapperInterface $ dataMapper = null ) { if ( empty ( $ dataMapper ) ) { try { $ dataMapper = $ this -> unitOfWork -> getDataMapper ( $ entityClass ) ; } catch ( \ RuntimeException $ e ) { $ dataMapper = $ this -> createDataMapper ( $ entityClass ) ; } } return new Reposit...
Gets a repository for an entity class .
10,510
private function createEntityBuilder ( $ dataDirectory ) { $ strategy = new RecursiveDirectoryStrategy ( $ dataDirectory ) ; $ locator = new Locator ( [ $ strategy ] ) ; $ builder = new EntityBuilder ( $ locator , $ this ) ; return $ builder ; }
Creates an EntityBuilder
10,511
private function createDataMapper ( $ entityClass ) { $ dataMapperClass = isset ( $ this -> config [ 'dataMapper' ] ) ? $ this -> config [ 'dataMapper' ] : DoctrineDataMapper :: class ; $ meta = $ this -> builder -> getMeta ( $ entityClass ) ; if ( $ meta -> storage [ 'type' ] == 'api' ) { $ dataMapperClass = $ meta ->...
Creates a DataMapper
10,512
protected static function matchCase ( $ value , $ comparison ) { $ functions = [ 'mb_strtolower' , 'mb_strtoupper' , 'ucfirst' , 'ucwords' ] ; foreach ( $ functions as $ function ) { if ( call_user_func ( $ function , $ comparison ) === $ comparison ) { return call_user_func ( $ function , $ value ) ; } } return $ valu...
Attempt to match the case on two strings .
10,513
public static function rtrimWord ( $ string , $ word ) { $ end = mb_substr ( $ string , 0 - mb_strlen ( $ word ) ) ; if ( $ end != $ word ) { return $ string ; } return mb_substr ( $ string , 0 , mb_strlen ( $ string ) - mb_strlen ( $ word ) ) ; }
Trims a word out of a string
10,514
public static function isSequential ( $ value , $ strict = false ) { if ( $ value === [ ] ) { return true ; } if ( ! is_object ( $ value ) && ! is_array ( $ value ) ) { return false ; } $ hasArrayAccess = is_array ( $ value ) || $ value instanceof ArrayAccess ; $ isTraversable = is_array ( $ value ) || $ value instance...
Return true if the passed object or array is a sequence
10,515
public static function first ( $ value ) { if ( is_array ( $ value ) && $ value ) { reset ( $ value ) ; return current ( $ value ) ; } if ( ! $ value ) { return null ; } if ( is_string ( $ value ) ) { return $ value [ 0 ] ; } if ( ! is_object ( $ value ) ) { return null ; } if ( $ value instanceof ArrayAccess && isset ...
Return the first item fo the passed value . ( First array item first letter first object item .
10,516
public static function last ( $ value ) { if ( is_array ( $ value ) && $ value ) { return end ( $ value ) ; } if ( ! $ value ) { return null ; } if ( is_string ( $ value ) ) { return mb_substr ( $ value , - 1 ) ; } if ( ! is_object ( $ value ) ) { return null ; } if ( ! $ value instanceof Traversable ) { return null ; ...
Return the last item fo the passed value . ( Last array item last letter last object item .
10,517
public static function keys ( $ value ) { if ( is_array ( $ value ) ) { return array_keys ( $ value ) ; } if ( ! is_object ( $ value ) ) { return [ ] ; } if ( ! $ value instanceof Traversable ) { return array_keys ( get_object_vars ( $ value ) ) ; } return array_keys ( iterator_to_array ( $ value , true ) ) ; }
Return the keys of the passed array or object
10,518
public function separator ( $ firstLines , $ delimiter = '"' ) { $ lines = $ this -> toCheckableLines ( $ firstLines ) ; $ separatorsByCount = $ this -> sortSeparatorsByHighestCount ( $ lines [ 0 ] , $ delimiter ) ; $ highestCount = max ( array_keys ( $ separatorsByCount ) ) ; if ( $ highestCount < 2 ) { return '' ; } ...
Detect the separator char . CSV Files with one line are invalid by definition .
10,519
protected function sortSeparatorsByHighestCount ( $ line , $ delimiter ) { $ separatorsByCount = [ ] ; foreach ( $ this -> separators as $ separator ) { $ data = str_getcsv ( $ line , $ separator , $ delimiter ) ; $ count = count ( $ data ) ; if ( ! isset ( $ separatorsByCount [ $ count ] ) ) { $ separatorsByCount [ $ ...
Return an array keyed by the column count of each separator
10,520
protected function toCheckableLines ( $ firstLines ) { $ lines = explode ( "\n" , $ this -> charsetGuard -> withoutBOM ( $ firstLines ) ) ; if ( count ( $ lines ) < 2 ) { throw new DetectionFailedException ( 'No lines found to detect separator' ) ; } return $ lines ; }
Read each line into an array . If there is only one or zero lines fail .
10,521
protected function containsOnlyColumnNames ( array $ row ) { $ last = count ( $ row ) - 1 ; foreach ( $ row as $ i => $ column ) { if ( ! $ this -> isColumnName ( $ column , $ i == $ last ) ) { return false ; } } return true ; }
Check if every passed columnName in the passed array is actually one
10,522
protected function isColumnName ( $ column , $ allowEmpty = false ) { if ( is_numeric ( $ column ) ) { return false ; } if ( trim ( $ column ) === '' ) { return $ allowEmpty ? true : false ; } return preg_match ( '/\w*[a-zA-Z]\w*/u' , $ column ) > 0 ; }
Check if a supposed column name is really one
10,523
protected function collectInvalidColumns ( array $ row ) { $ invalidColumns = [ ] ; foreach ( $ row as $ column ) { if ( ! $ this -> isColumnName ( $ column ) ) { $ invalidColumns [ ] = $ column ; } } return $ invalidColumns ; }
Collects invalid column names for better error messages
10,524
protected function collectDoubledColumns ( array $ row ) { $ foundNames = [ ] ; $ doubledColumns = [ ] ; foreach ( $ row as $ column ) { if ( isset ( $ foundNames [ $ column ] ) ) { $ doubledColumns [ ] = $ column ; } $ foundNames [ $ column ] = true ; } return $ doubledColumns ; }
Collects double column names for better error messages
10,525
public function setOperator ( $ operator ) { if ( $ this -> allowedOperators && ! in_array ( $ operator , $ this -> allowedOperators ) ) { throw new UnsupportedParameterException ( 'This constraint only accepts operators: ' . implode ( ',' , $ this -> allowedOperators ) ) ; } $ this -> operator = $ operator ; return $ ...
Set the operator of this constraint .
10,526
protected function renderOperatorString ( ) { $ parameters = $ this -> parameters ? $ this -> renderParameters ( $ this -> parameters ) : '' ; if ( $ this -> operator ) { return $ this -> operator . ( $ parameters ? " $parameters" : '' ) ; } return $ this -> name . "($parameters)" ; }
Render the operator formatted string
10,527
protected function renderNameString ( ) { $ parameters = $ this -> parameters ? $ this -> renderParameters ( $ this -> parameters ) : '' ; return $ parameters ? "{$this->name}:$parameters" : $ this -> name ; }
Render the name formatted string
10,528
protected function renderParameters ( array $ parameters , $ recursion = false ) { $ isOperatorFormat = $ this -> toStringFormat == 'operator' ; $ separator = $ isOperatorFormat ? ', ' : ',' ; $ rendered = [ ] ; foreach ( $ parameters as $ parameter ) { if ( $ parameter === null ) { $ rendered [ ] = 'null' ; continue ;...
Renders the parameters as a string
10,529
public function setCharacters ( Array $ characters ) { if ( count ( $ characters ) !== count ( array_filter ( $ characters , 'is_string' ) ) ) { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, characters, to be an array of " . "strings" ) ; } $ this -> characters = $ characters ; return $...
Sets the chunk s current characters
10,530
public function getNextCharacter ( ) { $ next = next ( $ this -> characters ) ; if ( $ next === false && $ this -> chunker -> hasNextChunk ( ) ) { $ this -> read ( $ this -> chunker -> getNextChunk ( ) ) ; $ next = reset ( $ this -> characters ) ; } return $ next ; }
Returns the next character
10,531
public function getPreviousCharacter ( ) { $ previous = prev ( $ this -> characters ) ; if ( $ previous === false && $ this -> chunker -> hasPreviousChunk ( ) ) { $ this -> read ( $ this -> chunker -> getPreviousChunk ( ) ) ; $ previous = end ( $ this -> characters ) ; } return $ previous ; }
Returns the previous character
10,532
public function reset ( ) { $ this -> characters = [ ] ; $ this -> chunker -> reset ( ) ; $ this -> read ( $ this -> chunker -> current ( ) ) ; return ; }
Resets the stream s internal pointer
10,533
protected function hasNextCharacter ( ) { return key ( $ this -> characters ) !== null && array_key_exists ( key ( $ this -> characters ) + 1 , $ this -> characters ) ; }
Returns true if a next character exists in the current chunk
10,534
protected function hasPreviousCharacter ( ) { return key ( $ this -> characters ) !== null && array_key_exists ( key ( $ this -> characters ) - 1 , $ this -> characters ) ; }
Returns true if a previous character exists in the current chunk
10,535
protected function read ( $ chunk ) { if ( ! is_string ( $ chunk ) && $ chunk !== false ) { throw new \ InvalidArgumentException ( __METHOD__ . "() expects parameter one, chunk, to be a string or false" ) ; } $ this -> characters = [ ] ; if ( is_string ( $ chunk ) && strlen ( $ chunk ) > 0 ) { $ len = mb_strlen ( $ chu...
Reads a chunk into the stream s characters array
10,536
public static function lastIndexOf ( array $ array , callable $ predicate ) : int { for ( $ index = count ( $ array ) - 1 ; $ index >= 0 ; -- $ index ) { if ( $ predicate ( $ array [ $ index ] ) ) { return $ index ; } } return - 1 ; }
Returns index of last element of the array for which predicate is true . Returns - 1 if none .
10,537
public function prepareEntity ( $ attributes ) { $ this -> fieldAliases = [ ] ; $ attributes [ 'class' ] = $ attributes [ 'name' ] ; $ attributes [ 'name' ] = preg_replace ( '~^.*?(\w+)$~' , '\1' , $ attributes [ 'class' ] ) ; $ this -> prefix = 'COM_' . strtoupper ( $ attributes [ 'name' ] ) . '_FIELD_' ; return $ att...
Parser callback for onBeforeEntity event
10,538
public function handleField ( Field $ field ) { $ prefix = $ this -> prefix . strtoupper ( $ field -> name ) ; if ( ! isset ( $ field -> label ) ) { $ field -> label = $ prefix . '_LABEL' ; } if ( preg_match ( '~^([A-Z_]+)$~' , $ field -> label , $ match ) ) { $ prefix = $ match [ 1 ] ; } if ( preg_match ( '~^([A-Z_]+?...
Parser callback for onAfterField event
10,539
private function locateDescription ( $ entityClass ) { $ entityName = preg_replace ( '~^.*?(\w+)$~' , '\1' , $ entityClass ) ; $ definitionFile = $ entityName . '.xml' ; $ filename = $ this -> locator -> findFile ( $ definitionFile ) ; if ( ! is_null ( $ filename ) ) { return $ filename ; } throw new EntityNotDefinedEx...
Locate the description file
10,540
private function parseDescription ( $ filename , $ entityClass ) { $ parser = new XmlParser ( ) ; $ parser -> open ( $ filename ) ; $ definition = $ parser -> parse ( [ 'onBeforeEntity' => [ $ this , 'prepareEntity' ] , 'onAfterEntity' => [ $ this , 'handleEntity' ] , 'onAfterField' => [ $ this , 'handleField' ] , 'onB...
Parse the description file
10,541
public function count ( ) { if ( $ this -> count == null ) { $ this -> count = $ this -> itemProvider -> count ( $ this -> method , $ this -> criterias ( ) ) ; } return $ this -> count ; }
Count all results .
10,542
protected function getResultOnce ( ) { if ( $ this -> result !== null ) { return $ this -> result ; } $ this -> result = $ this -> randomCombinations ? $ this -> getRandomizedResult ( ) : $ this -> getFromProvider ( $ this -> limit ) ; return $ this -> result ; }
Loads the result .
10,543
protected function buildRandomIntegers ( $ count , $ max = null , $ excludes = [ ] , $ unique = true ) { $ max = $ max ? : $ count ; if ( ! $ unique ) { $ numbers = [ ] ; for ( $ i = 0 ; $ i < $ count ; ++ $ i ) { $ numbers [ ] = rand ( 0 , $ max - 1 ) ; } return $ numbers ; } if ( $ count > $ max && $ unique ) { throw...
Create some random integers .
10,544
public function run ( $ taskId , $ operation , array $ arguments ) { try { $ lambda = new Lambda ( $ operation , $ this -> ioc ) ; if ( $ lambda -> isInstanceMethod ( ) ) { $ this -> connectHooks ( $ taskId , $ lambda -> getCallInstance ( ) ) ; } $ this -> taskRepository -> write ( $ taskId , [ 'state' => Queue :: RUNN...
Run the desired task and log its state changes .
10,545
protected function connectHooks ( $ taskId , $ jobObject ) { if ( $ jobObject instanceof Chatty ) { $ jobObject -> onMessage ( function ( $ message , $ level = Chatty :: INFO ) use ( $ taskId ) { $ this -> writeMessage ( $ taskId , $ message , $ level ) ; } ) ; } if ( $ jobObject instanceof PublishesProgress ) { $ jobO...
Log messages and progress if this is emitted by the operation .
10,546
protected function exceptionMessage ( \ Exception $ e ) { return get_class ( $ e ) . ' in ' . $ e -> getFile ( ) . ':' . $ e -> getLine ( ) . ' "' . $ e -> getMessage ( ) . '"' ; }
Format an exception for logging it .
10,547
public function register ( Container $ container , $ alias = null ) { $ container -> set ( 'Repository' , [ $ this , 'createRepositoryFactory' ] , true , true ) ; if ( ! empty ( $ alias ) ) { $ container -> alias ( $ alias , 'Repository' ) ; } }
Registers a RepositoryFactory with the container
10,548
public function createRepositoryFactory ( ContainerInterface $ container ) { if ( empty ( $ this -> configFile ) ) { $ this -> configFile = $ container -> get ( 'ConfigDirectory' ) . '/config/database.ini' ; } $ config = parse_ini_file ( $ this -> configFile , true ) ; $ configuration = new Configuration ; $ logger = n...
Creates a RepositoryFactory
10,549
protected function readNext ( $ handle , $ chunkSize ) { if ( feof ( $ handle ) ) { return null ; } $ line = $ this -> readLine ( $ handle , $ chunkSize ) ; return $ line === '' ? $ this -> readNext ( $ handle , $ chunkSize ) : $ line ; }
Read the next line and return it . Skip empty lines . The line breaks will be removed .
10,550
public function count ( ) { $ handle = $ this -> createHandle ( $ this -> getFilePath ( ) ) ; $ lineCount = 0 ; while ( ! feof ( $ handle ) ) { $ line = $ this -> readLine ( $ handle , null ) ; if ( $ line !== '' ) { ++ $ lineCount ; } } fclose ( $ handle ) ; return $ lineCount ; }
Return the amount of lines .
10,551
public static function register ( $ className ) { $ dispatcher = GeneralUtility :: makeInstance ( 'TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher' ) ; $ dispatcher -> connect ( 'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Backend' , 'afterInsertObject' , $ className , 'afterInsertObject' ) ; $ dispatcher -> connect ( 'TYPO...
Register the given entity slot class .
10,552
protected function getEventMessage ( Event $ event ) { $ sanitizedText = $ this -> getSanitizedText ( $ event ) ; $ message = sprintf ( "_e{%d,%d}:%s|%s|d:%d|h:%s|t:%s" , strlen ( $ event -> getTitle ( ) ) , strlen ( $ sanitizedText ) , $ event -> getTitle ( ) , $ sanitizedText , $ event -> getTimeStamp ( ) , $ event -...
Builds the event udp message
10,553
public function fromWp ( \ WP_Error $ WP_Error ) : CoreClasses \ Core \ Error { $ Error = $ this -> c :: error ( ) ; foreach ( $ WP_Error -> errors as $ _code => $ _messages ) { $ _slug = $ this -> c :: nameToSlug ( $ _code ) ; $ _data = $ WP_Error -> error_data [ $ _code ] ?? null ; foreach ( $ _messages as $ _message...
Converts a WP_Error .
10,554
public function isWebpage ( $ url ) { $ url = filter_var ( $ url , FILTER_VALIDATE_URL ) ; if ( ! strlen ( $ url ) ) { return false ; } $ c = curl_init ( ) ; curl_setopt ( $ c , CURLOPT_URL , $ url ) ; curl_setopt ( $ c , CURLOPT_HEADER , 1 ) ; curl_setopt ( $ c , CURLOPT_NOBODY , 1 ) ; curl_setopt ( $ c , CURLOPT_RETU...
Check whether a given URL is actually an html page
10,555
public function extractTitle ( $ content , $ retrieveTitle = false ) { if ( $ retrieveTitle ) { } else { if ( $ this -> isImage ( $ content ) ) { return 'Image: ' . basename ( $ content ) ; } if ( $ this -> isWebpage ( $ content ) ) { return 'Website: ' . basename ( $ content ) ; } return DBField :: create_field ( 'Tex...
Extract a title from a given piece of content
10,556
public function convertPostContent ( $ post ) { $ content = $ post -> Content ; $ lines = explode ( "\n" , $ content ) ; $ newContent = array ( ) ; $ title = '' ; $ converted = false ; $ convertedLinks = array ( ) ; foreach ( $ lines as $ line ) { $ url = trim ( $ line ) ; if ( strlen ( $ url ) && $ this -> isWebpage (...
Analyse a post and see if there s particular content that should be extracted
10,557
protected function autoAssignAttributes ( ) { $ attributes = isset ( $ this -> defaultAttributes ) ? $ this -> defaultAttributes : [ ] ; $ this -> fillAttributes ( $ attributes , false ) ; }
Provide the attributes to auto fill them
10,558
public function checkIfSemaphoreIsLocked ( $ id , string $ section ) : int { $ key = $ this -> getSemaphoreKey ( $ id , $ section ) ; if ( ! $ this -> cache -> has ( $ key , [ 'semaphore' , $ section ] ) ) { return 0 ; } return ( int ) $ this -> cache -> get ( $ key , [ 'semaphore' , $ section ] ) ; }
Check if a semaphore is locked or free . Return 1 if locked or 0 if unlocked .
10,559
public function lockSemaphore ( $ id , string $ section ) { $ key = $ this -> getSemaphoreKey ( $ id , $ section ) ; $ this -> cache -> put ( $ key , 1 , [ 'semaphore' , $ section ] , $ this -> lockingTime ) ; }
Lock the semaphore with input key and section .
10,560
private function makePathRelative ( string $ path ) : string { return ( $ this -> projectDir === substr ( $ path , 0 , strlen ( $ this -> projectDir ) ) ) ? substr ( $ path , strlen ( $ this -> projectDir ) + 1 ) : $ path ; }
Makes the path relative to the project dir
10,561
private function fetchNamespaces ( NamespaceRegistry $ entryNamespaces ) : array { $ namespaces = [ ] ; foreach ( $ entryNamespaces as $ namespace => $ path ) { $ namespaces [ $ namespace ] = $ this -> makePathRelative ( $ path ) ; } return $ namespaces ; }
Fetches and prepares the namespaces
10,562
private function getPathMap ( array $ namespaces ) : array { $ pathMap = [ ] ; foreach ( $ namespaces as $ namespace => $ path ) { $ pathMap [ $ path ] = 1 + ( $ pathMap [ $ path ] ?? 0 ) ; } return $ pathMap ; }
Returns the path map . It contains the mapping from relative paths to how often they are registered .
10,563
private function generateTableRows ( array $ namespaces , bool $ hasDuplicatePath , array $ pathMap ) : array { $ rows = [ ] ; foreach ( $ namespaces as $ namespace => $ path ) { $ row = [ "<fg=yellow>@{$namespace}</>" , $ path , ] ; if ( $ hasDuplicatePath ) { $ warning = $ pathMap [ $ path ] > 1 ? '<fg=red>\\<!></>' ...
Generates the table rows
10,564
public function xTypeConfig ( ) { $ class = get_class ( $ this ) ; if ( ! isset ( _XTypeTraitStorage :: $ typeCache [ $ class ] ) ) { $ config = isset ( $ this -> xType ) ? $ this -> xType : [ ] ; _XTypeTraitStorage :: $ typeCache [ $ class ] = $ this -> bootXTypeConfig ( $ config ) ; } return _XTypeTraitStorage :: $ t...
Assign an array named xType to manually set an xtype config . This is much better than guessing the types
10,565
public function save ( ) { $ appname = $ this -> name ; $ temp = "no" ; $ temdirbase = FEnv :: get ( "framework.root" ) . "vendor/iumio-framework/Core/Additional/Manager/Module/App/AppTemplate" ; $ tempdir = ( $ temp == "no" ) ? $ temdirbase . '/notemplate/{appname}/' : $ temdirbase . '/template/{appname}/' ; Server ::...
Save an App
10,566
public function remove ( ) { $ f = json_decode ( file_get_contents ( FEnv :: get ( "framework.root" ) . "elements/config_files/core/apps.json" ) ) ; foreach ( $ f as $ one => $ val ) { if ( $ val -> name == $ this -> name ) { unset ( $ f -> $ one ) ; break ; } } $ f = json_encode ( $ f , JSON_PRETTY_PRINT ) ; file_put_...
Delete an app
10,567
public function getFull ( string $ key ) : string { if ( array_key_exists ( $ key , $ this -> map ) ) { return $ this -> map [ $ key ] ; } if ( in_array ( $ key , $ this -> map ) ) { return $ key ; } throw new JoryException ( 'Key ' . $ key . ' is no valid Jory key.' ) ; }
Get the full for the given key .
10,568
public function getMinified ( string $ key ) : ? string { if ( array_key_exists ( $ key , $ this -> map ) ) { return $ key ; } $ foundKey = array_search ( $ key , $ this -> map ) ; if ( $ foundKey === false ) { throw new JoryException ( 'Key ' . $ key . ' is no valid Jory key.' ) ; } return $ foundKey ; }
Get the minified key for the given key .
10,569
public function get ( string $ key , bool $ minified = null ) : ? string { if ( is_null ( $ minified ) ) { $ minified = $ this -> minified ; } return $ minified ? $ this -> getMinified ( $ key ) : $ this -> getFull ( $ key ) ; }
Get a key .
10,570
public function getArrayValue ( array $ array , string $ key ) { foreach ( $ this -> getBoth ( $ key ) as $ loopKey ) { if ( array_key_exists ( $ loopKey , $ array ) ) { return $ array [ $ loopKey ] ; } } }
Get the value in an array on a given key . Checks both on full and minified key .
10,571
public function getStatisticsServices ( ) : array { $ services = $ this -> getAllServices ( ) ; $ counter = 0 ; $ senable = 0 ; foreach ( $ services as $ val ) { if ( $ val -> status == "enabled" ) { $ senable ++ ; } $ counter ++ ; } return ( array ( "number" => $ counter , "enabled" => $ senable ) ) ; }
Get service statistics
10,572
public function removeActivity ( string $ servicename ) : Renderer { $ removeservice = false ; $ file = JL :: open ( FEnv :: get ( "framework.config.core.services.file" ) ) ; foreach ( $ file as $ one => $ value ) { if ( $ one == $ servicename ) { unset ( $ file -> $ one ) ; $ removeservice = true ; break ; } } if ( $ ...
remove one service
10,573
public function createActivity ( ) : Renderer { $ name = $ this -> clean ( $ this -> get ( "request" ) -> get ( "name" ) ) ; $ status = $ this -> get ( "request" ) -> get ( "status" ) ; $ namespace = $ this -> get ( "request" ) -> get ( "namespace" ) ; if ( $ name == "" ) { return ( ( new Renderer ( ) ) -> jsonRenderer...
Create one service
10,574
public function editActivity ( string $ servicename ) : Renderer { $ status = $ this -> get ( "request" ) -> get ( "status" ) ; $ namespace = $ this -> get ( "request" ) -> get ( "namespace" ) ; if ( $ status == "" || ! in_array ( $ status , array ( "enabled" , "disabled" ) ) ) { return ( ( new Renderer ( ) ) -> jsonRe...
edit one service
10,575
private function clean ( string $ string , bool $ space_remove = true ) { $ string = trim ( $ string ) ; if ( $ space_remove ) { $ string = str_replace ( ' ' , '-' , $ string ) ; } return preg_replace ( '/[^A-Za-z0-9\-][_]/' , '' , $ string ) ; }
Clean a string
10,576
public function validate ( ) : void { $ this -> validateRootFilter ( ) ; $ this -> validateRelations ( ) ; $ this -> validateSorts ( ) ; $ this -> validateOffset ( ) ; $ this -> validateLimit ( ) ; $ this -> validateFields ( ) ; }
Validate the data given in the constructor Throws a JoryException on failure .
10,577
protected function validateRootFilter ( ) : void { $ rootFilter = $ this -> getArrayValue ( $ this -> joryArray , [ 'flt' , 'filter' ] ) ; if ( $ rootFilter === null || count ( $ rootFilter ) === 0 ) { return ; } $ this -> validateFilter ( $ rootFilter , $ this -> address . 'filter' ) ; }
Validate the filter part of the array .
10,578
protected function hasArrayKey ( array $ array , array $ keys ) : bool { foreach ( $ keys as $ key ) { if ( array_key_exists ( $ key , $ array ) ) { return true ; } } return false ; }
Tell if one of the given keys exists in array .
10,579
protected function validateRelations ( ) : void { $ relations = $ this -> getArrayValue ( $ this -> joryArray , [ 'rlt' , 'relations' ] ) ; if ( ! $ relations ) { return ; } if ( ! is_array ( $ relations ) ) { throw new JoryException ( 'The relation parameter should be an array. (Location: ' . $ this -> address . 'rela...
Validate the relations Throws a JoryException on failure .
10,580
protected function validateRelation ( $ name , $ jory ) : void { if ( empty ( $ name ) ) { throw new JoryException ( 'A relations name should not be empty. (Location: ' . $ this -> address . 'relations)' ) ; } ( new self ( $ jory , $ this -> address . $ name ) ) -> validate ( ) ; }
Validate a single relation Throws a JoryException on failure .
10,581
protected function validateSorts ( ) : void { $ sorts = $ this -> getArrayValue ( $ this -> joryArray , [ 'srt' , 'sorts' ] ) ; if ( ! $ sorts ) { return ; } if ( ! is_array ( $ sorts ) ) { throw new JoryException ( 'The sorts parameter should be an array. (Location: ' . $ this -> address . 'sorts)' ) ; } foreach ( $ s...
Validate the sorts Throws a JoryException on failure .
10,582
protected function validateOffset ( ) : void { $ offset = $ this -> getArrayValue ( $ this -> joryArray , [ 'ofs' , 'offset' ] ) ; if ( $ offset === null ) { return ; } if ( ! is_int ( $ offset ) ) { throw new JoryException ( 'The offset parameter should be an integer value. (Location: ' . $ this -> address . 'offset)'...
Validate the offset value Throws a JoryException on failure .
10,583
protected function validateLimit ( ) : void { $ limit = $ this -> getArrayValue ( $ this -> joryArray , [ 'lmt' , 'limit' ] ) ; if ( $ limit === null ) { return ; } if ( ! is_int ( $ limit ) ) { throw new JoryException ( 'The limit parameter should be an integer value. (Location: ' . $ this -> address . 'limit)' ) ; } ...
Validate the limit value Throws a JoryException on failure .
10,584
protected function validateFields ( ) : void { $ fields = $ this -> getArrayValue ( $ this -> joryArray , [ 'fld' , 'fields' ] ) ; if ( $ fields === null ) { return ; } if ( ! is_array ( $ fields ) ) { throw new JoryException ( 'The fields parameter must be an array. (Location: ' . $ this -> address . 'fields)' ) ; } f...
Validate the fields Throws a JoryException on failure .
10,585
public function openFileAsArray ( string $ filepath ) : array { if ( $ filepath == $ this -> filepath && $ this -> file != null ) { return ( $ this -> file ) ; } if ( ! file_exists ( $ filepath ) ) { Server :: create ( $ filepath , 'file' ) ; } if ( ! is_readable ( $ filepath ) ) { throw new Server500 ( new \ ArrayObje...
Open file and returning an array of each line
10,586
public function size ( ) : int { if ( $ this -> file == null ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Cannot get size for unopened file" , "solution" => "Please open the file with [FileListener::open] before trying to get the size." ) ) ) ; } return ( filesize ( $ this -> filepath ) ) ; }
Getting the file size
10,587
public function invoke ( ControllerContextInterface $ context , ControllerDispatch $ dispatch ) { $ controller = $ this -> createController ( $ dispatch -> controllerClass ( ) ) ; $ controller -> runWithContext ( $ context ) ; $ method = $ dispatch -> handlerMethod ( ) ; $ method -> invokeArgs ( $ controller , $ dispat...
Invokes the controller action returning view data
10,588
private function createController ( \ ReflectionClass $ controllerName ) { $ controller = $ this -> container -> make ( $ controllerName -> getName ( ) ) ; return $ controller ; }
Uses the dependency container to create the controller
10,589
protected function setFilters ( Jory $ jory ) : void { $ data = $ this -> getArrayValue ( $ this -> joryArray , 'flt' ) ; if ( $ data ) { $ jory -> setFilter ( $ this -> getFilterFromData ( $ data ) ) ; } }
Set the filters on the jory object based on the given data in constructor .
10,590
protected function setRelations ( Jory $ jory ) : void { $ relations = $ this -> getArrayValue ( $ this -> joryArray , 'rlt' ) ; if ( $ relations ) { $ relations = $ this -> convertDotNotatedRelations ( $ relations ) ; foreach ( $ relations as $ name => $ joryData ) { $ subJory = ( new self ( $ joryData ) ) -> getJory ...
Set the relations on the jory object based on the given data in constructor .
10,591
protected function setSorts ( Jory $ jory ) : void { $ sorts = $ this -> getArrayValue ( $ this -> joryArray , 'srt' ) ; if ( $ sorts ) { foreach ( $ sorts as $ sort ) { $ order = 'asc' ; if ( substr ( $ sort , 0 , 1 ) === '-' ) { $ order = 'desc' ; $ sort = substr ( $ sort , 1 ) ; } try { $ jory -> addSort ( new Sort ...
Set the sorts on the jory object based on the given data in constructor .
10,592
protected function setOffset ( Jory $ jory ) : void { $ offset = $ this -> getArrayValue ( $ this -> joryArray , 'ofs' ) ; if ( $ offset !== null ) { $ jory -> setOffset ( $ offset ) ; } }
Set the offset on the jory object based on the given data in constructor .
10,593
protected function setLimit ( Jory $ jory ) : void { $ limit = $ this -> getArrayValue ( $ this -> joryArray , 'lmt' ) ; if ( $ limit !== null ) { $ jory -> setLimit ( $ limit ) ; } }
Set the limit on the jory object based on the given data in constructor .
10,594
protected function setFields ( Jory $ jory ) : void { $ fields = $ this -> getArrayValue ( $ this -> joryArray , 'fld' ) ; $ jory -> setFields ( $ fields ) ; }
Set the fields on the jory object based on the given data in constructor .
10,595
protected function convertDotNotatedRelations ( $ relations ) { $ dottedRelations = [ ] ; foreach ( $ relations as $ name => $ joryData ) { $ exploded = explode ( '.' , $ name ) ; if ( count ( $ exploded ) > 1 ) { $ firstRelation = $ exploded [ 0 ] ; unset ( $ exploded [ 0 ] ) ; $ dottedRelations [ $ firstRelation ] [ ...
Convert relations which are written in dot - notation to subrelations in the relations array .
10,596
public function decompress ( LocalFileNodeInterface $ node , array $ options = [ ] ) { $ pathInfo = pathinfo ( $ node -> getPath ( ) ) ; if ( ! $ node -> exists ( ) ) { throw new InvalidArgumentException ( "The file: $node does not exist" ) ; } $ outputFile = $ node -> getClone ( ) -> setPath ( $ pathInfo [ 'dirname' ]...
Decompress a file and return the decompressed file
10,597
public function invoke ( callable $ callback , $ params = [ ] ) { if ( is_callable ( $ callback ) ) { return call_user_func_array ( $ callback , $ this -> resolveCallableDependencies ( $ callback , $ params ) ) ; } else { return call_user_func_array ( $ callback , $ params ) ; } }
Invoke a callback with resolving dependencies in parameters .
10,598
public function getCompression ( LocalFileNodeInterface $ file ) { $ cmd = "file --brief --uncompress --mime {$file->getPath()}" ; $ process = $ this -> getProcess ( $ cmd ) ; $ process -> mustRun ( ) ; $ result = $ process -> getOutput ( ) ; if ( preg_match ( '/compressed-encoding=application\/(?:x-)?(.+?);/i' , $ res...
Find the compression of a file
10,599
private function checkSelecaoUnique ( Meta $ meta ) : string { $ mult = "" ; $ tpl = new \ Helpers \ Template ( "form" ) ; foreach ( $ meta -> getSelect ( ) as $ select ) { if ( ! empty ( $ select -> getValue ( ) ) ) { $ dr = new Dicionario ( $ select -> getRelation ( ) ) ; $ dr -> setData ( $ select -> getValue ( ) ) ...
Busca por campos mult relacionais que precisam ser selecionados