idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
50,300
public function link ( $ url , $ content = '' , $ options = [ ] , $ safe = false ) { if ( is_null ( $ content ) ) { $ content = $ url ; } return '<a href="' . $ this -> _generator -> generateUrl ( $ url ) . '"' . self :: attributes ( $ options ) . '>' . self :: encode ( $ content , $ safe ) . '</a>' ; }
Generates an anchor tag .
50,301
public function image ( $ url , $ alt = null , $ options = [ ] ) { $ options [ 'alt' ] = $ alt ; return '<img src="' . $ this -> _generator -> asset ( $ url ) . '"' . self :: attributes ( $ options ) . '>' ; }
Creates an image element .
50,302
public function whereInStrict ( string $ key , $ values ) : Collection { return $ this -> whereIn ( $ key , $ values , true ) ; }
Filter items by the given key value pair using strict comparison .
50,303
public function arsort ( int $ option = SORT_REGULAR ) : Collection { $ index = 0 ; $ items = $ this -> items ; foreach ( $ items as & $ item ) { $ item = [ $ index ++ , $ item ] ; } uasort ( $ items , function ( $ a , $ b ) use ( $ option ) { if ( $ a [ 1 ] === $ b [ 1 ] ) { return $ a [ 0 ] - $ b [ 0 ] ; } $ set = [ ...
Sort an array in reverse order and maintain index association .
50,304
public function natcasesort ( ) : Collection { $ index = 0 ; $ items = $ this -> items ; foreach ( $ items as & $ item ) { $ item = [ $ index ++ , $ item ] ; } uasort ( $ items , function ( $ a , $ b ) { $ result = strnatcasecmp ( $ a [ 1 ] , $ b [ 1 ] ) ; return $ result === 0 ? $ a [ 0 ] - $ b [ 0 ] : $ result ; } ) ...
Sort an array using a case insensitive natural order algorithm .
50,305
public function natsort ( ) : Collection { $ index = 0 ; $ items = $ this -> items ; foreach ( $ items as & $ item ) { $ item = [ $ index ++ , $ item ] ; } uasort ( $ items , function ( $ a , $ b ) { $ result = strnatcmp ( $ a [ 1 ] , $ b [ 1 ] ) ; return $ result === 0 ? $ a [ 0 ] - $ b [ 0 ] : $ result ; } ) ; foreac...
Sort an array using a natural order algorithm .
50,306
public function uksort ( callable $ callback ) : Collection { $ items = $ this -> items ; $ keys = array_combine ( array_keys ( $ items ) , range ( 1 , count ( $ items ) ) ) ; uksort ( $ items , function ( $ a , $ b ) use ( $ callback , $ keys ) { $ result = call_user_func ( $ callback , $ a , $ b ) ; return $ result =...
Sort an array by keys using a user - defined comparison function .
50,307
public function usort ( callable $ callback ) : Collection { $ index = 0 ; $ items = $ this -> items ; foreach ( $ items as & $ item ) { $ item = [ $ index ++ , $ item ] ; } usort ( $ items , function ( $ a , $ b ) use ( $ callback ) { $ result = call_user_func ( $ callback , $ a [ 1 ] , $ b [ 1 ] ) ; return $ result =...
Sort an array by values using a user - defined comparison function .
50,308
public function initialize ( Listener $ listener ) { $ this -> tracker -> initialize ( $ listener ) ; $ this -> wathedPaths = $ listener -> getPaths ( ) ; }
Initialize new listener
50,309
public function evaluate ( ) { $ this -> tracker -> clearChangeSet ( ) ; $ this -> modified = array ( ) ; $ inEvents = inotify_read ( $ this -> inotify ) ; $ inEvents = is_array ( $ inEvents ) ? $ inEvents : array ( ) ; foreach ( $ inEvents as $ inEvent ) { $ this -> translateEvent ( $ inEvent ) ; } }
Evaluate Filesystem changes
50,310
public function manage ( ) { $ this -> initLoop ( ) ; $ this -> context = new Context ( $ this -> loop ) ; $ this -> initStreams ( ) ; $ this -> pmReplySocket = $ this -> context -> getSocket ( \ ZMQ :: SOCKET_REP ) ; $ this -> dtoContainer = new DtoContainer ( ) ; $ this -> dtoContainer -> setDto ( new LmStateDto ( ) ...
Send periodic signals about CPU and memory status ; total and per PID
50,311
public function fromFile ( $ filePath ) { $ pemString = file_get_contents ( $ filePath ) ; if ( ! $ pemString ) { throw new RuntimeException ( "Unable to read file at path '$filePath'." ) ; } try { $ certificate = $ this -> fromString ( $ pemString ) ; } catch ( Exception $ e ) { throw new RuntimeException ( "File at '...
Create a certificate from a file path .
50,312
private function formatKey ( $ certData ) { return X509Certificate :: PEM_HEADER . PHP_EOL . chunk_split ( $ certData , 64 , PHP_EOL ) . X509Certificate :: PEM_FOOTER . PHP_EOL ; }
Given the certData string turn it back into a proper PEM encoded certificate .
50,313
public function detail ( ) { $ url = $ this -> montage -> url ( 'schema-detail' , $ this -> name ) ; return $ this -> montage -> request ( 'get' , $ url ) ; }
Returns the details of a specific Montage schema .
50,314
protected function parseSubSelect ( $ query ) { if ( $ query instanceof self ) { $ query -> columns = [ $ query -> columns [ 0 ] ] ; return [ $ query -> toSql ( ) , $ query -> getBindings ( ) ] ; } elseif ( is_string ( $ query ) ) { return [ $ query , [ ] ] ; } else { throw new \ InvalidArgumentException ( ) ; } }
Parse the sub - select query into SQL and bindings .
50,315
private function loadLateLoadProperty ( ) { $ pks = $ this -> pgClass -> getPrimaryKeys ( ) ; $ this -> lateLoadProperty = ( count ( $ pks ) === 1 ) ? $ pks -> pop ( ) -> name : null ; }
Determine the lateLoadProperty
50,316
private function getIsZombieFunction ( ) { $ zombieTests = $ this -> pgClass -> getAttributes ( ) -> filter ( function ( $ e ) { return $ e -> isZombie ( ) ; } ) -> map ( function ( $ zombieCol ) { return sprintf ( "( null === \$this->data['%s'] )" , addslashes ( $ zombieCol -> name ) ) ; } ) ; if ( $ zombieTests ) { $...
Produce the isZombie method
50,317
private function getSqlInterfaceFunction ( ) { if ( count ( $ this -> keyProperties ) !== 1 ) { $ content = " throw new \LogicException('Normality can\\'t (yet) handle tables without a primary key or multi-column primary keys.\\n" . "Please extend the generator or overload {$this->pgClass->getEntityName()}->parse()....
Produce the static entity function data
50,318
private function generateGetSetLinksCallback ( & $ get , & $ set , $ name , $ link ) { foreach ( $ link -> foreignEntities as $ foreignEntity ) { $ nameForeignEntity = $ this -> getSetAlias ( "{$foreignEntity}s" , 'data' ) ; $ this -> additionalProperties [ ] = $ nameForeignEntity ; $ this -> class -> addUses ( 'Bond\\...
many to many references to foreign entities
50,319
private function generateGetSetReferenceCallback ( & $ get , & $ set , $ reference ) { if ( ! ( $ property = $ this -> getSetAlias ( $ reference , 'reference' ) ) ) { return ; } $ this -> additionalProperties [ ] = $ property ; $ this -> class -> addUses ( 'Bond\\Repository' ) ; $ this -> class -> addUses ( 'Bond\\Enti...
References to foreign entities in a 1 - > 1 or 1 - > many way . Think Contact - > ContactUser or Contact - > Addresses
50,320
private function generateGetSetBoolCallback ( & $ get , & $ set , $ columnName ) { $ this -> class -> classComponents [ ] = new FunctionDeclaration ( "getset.{$columnName}.get" , $ this -> generateGetCallbackForBool ( $ columnName ) ) ; $ this -> class -> classComponents [ ] = new FunctionDeclaration ( "getset.{$column...
Bool columns .
50,321
private function getSymfonyCompatibleGettersAndSetters ( ) { return array ( ) ; if ( ! $ this -> symfonyFormGetters ) { return array ( ) ; } $ output = explode ( "\n" , <<<PHP/*** Symfony2 compatible getters and setters.* These are __not__ to be used by Bond code. These have be depreciated.*/// /*PHP ) ; $ output = ar...
Build normality compatible getters and setters
50,322
private function addSymfonyFormCompatibleGetter ( $ name ) { $ fnName = "get" . \ Bond \ pascal_case ( $ name ) ; $ fnBody = sprintf ( "function %s() { return \$this->get('%s'); }" , $ fnName , addslashes ( $ name ) ) ; $ this -> class -> classComponents [ ] = new FunctionDeclaration ( $ fnName , $ fnBody ) ; }
Build a symfony2 form compatible getter
50,323
private function getFormChoiceTextFunction ( ) { $ columns = $ this -> pgClass -> getAttributes ( ) ; $ columnsSelected = array ( ) ; foreach ( $ columns as $ column ) { $ tags = \ Bond \ extract_tags ( $ column , 'normality' ) ; if ( isset ( $ tags [ 'form-choicetext' ] ) ) { $ columnsSelected [ ] = $ column ; } } swi...
Form choice text function
50,324
private function getSymfonyValidatorConstraints ( ) { $ constraints = array ( ) ; $ this -> loadUnsettableProperties ( ) ; foreach ( $ this -> dataTypes as $ column => $ type ) { if ( $ type -> isInherited ( ) ) { continue ; } if ( in_array ( $ column , $ this -> unsetableProperties ) ) { continue ; } if ( ! $ type -> ...
Get Symfony validator contraints
50,325
private function getOperators ( $ dataClass , $ propertyPath ) { $ metadata = $ this -> registry -> getManagerForClass ( $ dataClass ) -> getClassMetadata ( $ dataClass ) ; if ( false === strpos ( $ propertyPath , '.' ) ) { if ( $ metadata -> hasAssociation ( $ propertyPath ) ) { if ( $ metadata -> isCollectionValuedAs...
Returns the operators according to association type targeted by the property path .
50,326
public static function log ( \ Throwable $ throwable , LoggerInterface $ instance , array $ context = [ ] ) : \ Throwable { $ context = Collection :: cast ( $ context , [ ] ) ; $ context [ 'exception' ] = $ throwable ; $ context [ 'backtrace' ] = false ; $ severity = $ throwable instanceof Helper \ ThrowableInterface ?...
Logger the \ Throwable with the proper severity and message
50,327
public function finish ( InstalledFileManager $ fileManager , FinalInstallManager $ finalInstall , EnvironmentManager $ environment ) { $ finalMessages = $ finalInstall -> runFinal ( ) ; $ finalStatusMessage = $ fileManager -> update ( ) ; $ finalEnvFile = $ environment -> getEnvContent ( ) ; return view ( 'vendor.inst...
Update installed file and display finished view .
50,328
public function item ( $ item , $ transformer , $ model_name = '' ) { $ resource = new Item ( $ item , $ transformer , $ model_name ) ; return $ this -> manager -> createData ( $ resource ) -> toArray ( ) ; }
Fractal transform a single item
50,329
public static function pull ( $ key , $ default = NULL ) { if ( false === is_string ( $ key ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ key ) ) , E_USER_ERROR ) ; } if ( true === isset ( static :: $ data [ $ key ] ) ) { $ default =...
Retrieve and delete an item
50,330
public static function get ( $ key , $ default = null ) { if ( false === is_string ( $ key ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ key ) ) , E_USER_ERROR ) ; } if ( true === isset ( static :: $ data [ $ key ] ) ) { return stati...
Retrieve data based on key
50,331
public static function all ( ) { $ cookies = [ ] ; foreach ( static :: $ data as $ key => $ value ) { if ( rtrim ( base64_encode ( base64_decode ( $ key , true ) ) , '=' ) === $ key ) { $ cookies [ base64_decode ( $ key ) ] = Hash :: decrypt ( static :: $ data [ $ key ] , Application :: get ( 'salt' ) ) ; } else { $ co...
Get all data from current session Cookie
50,332
public function setAttribute ( $ key , $ val ) { if ( is_null ( $ val ) && array_key_exists ( $ key , $ this -> attributes ) ) unset ( $ this -> attributes [ $ key ] ) ; else $ this -> attributes [ $ key ] = $ val ; }
Used to set attributes of the RequestContext
50,333
public function validate ( $ value , & $ filtered = null ) { if ( ! $ this -> validator -> validate ( $ value , $ filtered ) ) throw new ValidationException ( $ this -> validator -> getErrorMessage ( $ value ) ) ; return true ; }
Validate the value for this column .
50,334
public static function parseArray ( array $ data ) { $ type = strtoupper ( $ data [ 'data_type' ] ) ; if ( ! defined ( static :: class . '::' . $ type ) ) throw new InvalidValueException ( "Invalid column type: $type" ) ; return array ( 'name' => $ data [ 'column_name' ] , 'type' => $ type , 'max_length' => $ data [ 'c...
Parse deserialized array into valid arguments for column properties .
50,335
public function unserialize ( $ data ) { $ data = unserialize ( $ data ) ; $ args = self :: parseArray ( $ data ) ; $ this -> __construct ( $ args [ 'name' ] ) ; foreach ( $ args as $ property => $ value ) { if ( ! empty ( $ value ) ) $ this -> set ( $ property , $ value ) ; } return $ col ; }
Restore the column from its serialize form
50,336
public static function factory ( array $ data ) { $ type = ucfirst ( strtolower ( $ data [ 'data_type' ] ) ) ; $ args = self :: parseArray ( $ data ) ; $ classname = __NAMESPACE__ . "\\" . ucfirst ( strtolower ( $ args [ 'type' ] ) ) ; $ params = Hook :: execute ( 'Wedeto.DB.Schema.Column.Column.FindClass' , [ 'column_...
Create a column instance from an array .
50,337
public function xml ( ) : ? SimpleXMLElement { return simplexml_load_string ( utf8_encode ( $ this -> response -> getBody ( ) -> getContents ( ) ) , 'SimpleXMLElement' , LIBXML_NOCDATA | LIBXML_NOBLANKS ) ; }
Gets the body of the message as XML .
50,338
public function headers ( ) : array { return collect ( $ this -> response -> getHeaders ( ) ) -> mapWithKeys ( function ( $ v , $ k ) { return [ $ k => $ v [ 0 ] ] ; } ) -> all ( ) ; }
Retrieves all header values .
50,339
public function call ( ) { if ( ! $ this -> responseShouldHaveBody ( ) ) { $ this -> next -> call ( ) ; return ; } $ negotiator = new Negotiator ( ) ; $ format = $ negotiator -> getBest ( $ this -> app -> request ( ) -> headers ( 'Accept' ) ) ; if ( $ format && in_array ( ( $ type = $ format -> getValue ( ) ) , $ this ...
Ensure the provided content type is valid and set the proper response content type
50,340
public function contains ( $ token ) { $ token = ( string ) $ token ; $ this -> __validate ( $ token ) ; return $ this -> __contains ( $ token ) ; }
Checks if a the list of tokens contains the provided token .
50,341
public function replace ( $ old_token , $ new_token ) { $ updated = false ; $ old_token = ( string ) $ old_token ; $ new_token = ( string ) $ new_token ; $ this -> __validate ( $ old_token ) ; $ this -> __validate ( $ new_token ) ; if ( $ index = array_search ( $ old_token , $ this -> tokens , true ) ) { $ this -> toke...
Replace an existing token for a new one .
50,342
public function toggle ( $ token , $ force = null ) { $ output = null ; $ contains = $ this -> contains ( $ token ) ; if ( $ contains ) { if ( ! $ force ) { $ this -> __remove ( [ $ token ] ) ; $ change = false ; } else { $ change = true ; } } else { if ( false === $ force ) { $ change = false ; } else { $ this -> __ad...
If the name exists within the token list it will be removed . If name does not exist it will be added .
50,343
protected function __modify ( $ action , $ arguments ) { $ tokens = $ arguments ; $ method = "__{$action}" ; if ( 1 === count ( $ arguments ) ) { $ tokens = reset ( $ tokens ) ; if ( is_string ( $ tokens ) ) { $ tokens = explode ( ' ' , $ tokens ) ; } } if ( is_array ( $ tokens ) ) { $ tokens = array_map ( 'strval' , $...
Alters the list of tokens .
50,344
public function offsetSet ( $ offset , $ value ) { $ is_offset_string = is_string ( $ offset ) ; $ is_value_string = is_string ( $ value ) ; if ( null === $ offset && $ is_value_string ) { $ this -> add ( $ value ) ; } elseif ( is_bool ( $ value ) && $ is_offset_string ) { if ( $ value ) { $ this -> add ( $ offset ) ; ...
Append a token to the list and optionally remove an existing token .
50,345
public function offsetUnset ( $ offset ) { if ( is_int ( $ offset ) ) { unset ( $ this -> tokens [ $ offset ] ) ; } else { $ this -> remove ( $ offset ) ; } }
Remove a token .
50,346
public static function init ( $ configuration = array ( ) ) { $ smConfig = isset ( $ configuration [ 'service_manager' ] ) ? $ configuration [ 'service_manager' ] : array ( ) ; $ serviceManager = new ServiceManager ( new ServiceManagerConfig ( $ smConfig ) ) ; $ serviceManager -> setService ( 'ApplicationConfig' , $ co...
Static method for quick and easy initialization of the Application .
50,347
public function createAction ( string $ production_slug , AuthorizationCheckerInterface $ auth , TokenStorageInterface $ token , Request $ request ) : Response { $ production_repo = $ this -> em -> getRepository ( Production :: class ) ; if ( null === $ production = $ production_repo -> findOneBy ( [ 'slug' => $ produc...
Create a new schedule which is a collection of events .
50,348
public function readAction ( int $ id , string $ production_slug , AuthorizationCheckerInterface $ auth , PaginatorInterface $ paginator , Request $ request ) : Response { list ( $ schedule , $ production ) = $ this -> lookupEntity ( Schedule :: class , $ id , $ production_slug ) ; if ( ! $ auth -> isGranted ( 'view' ,...
Show a single schedule .
50,349
public function deleteAction ( string $ production_slug , int $ id , AuthorizationCheckerInterface $ auth , Request $ request ) : Response { list ( $ schedule , $ production ) = $ this -> lookupEntity ( Schedule :: class , $ id , $ production_slug ) ; if ( ! $ auth -> isGranted ( 'edit' , $ schedule ) ) { throw new Acc...
Delete a single schedule .
50,350
public function archiveAction ( string $ production_slug , PaginatorInterface $ paginator , AuthorizationCheckerInterface $ auth , Request $ request ) : Response { $ production_repo = $ this -> em -> getRepository ( Production :: class ) ; if ( null === $ production = $ production_repo -> findOneBy ( [ 'slug' => $ prod...
Show a list of archived schedules .
50,351
public function byUsernameAction ( Request $ request ) { $ term = $ request -> get ( 'username' ) ; $ users = $ this -> get ( 'asf_user.user.manager' ) -> getRepository ( ) -> findByUsernameContains ( $ term ) ; $ search = array ( ) ; foreach ( $ users as $ user ) { $ search [ ] = array ( 'id' => $ user -> getId ( ) , ...
Return list of users according to the search by username
50,352
public static function apply ( string $ text , $ context , string $ skip = '' , ? callable $ callback = null ) : string { $ context = Storage :: instance ( $ context ) ; $ output = '' ; $ delimiter = null ; for ( $ i = 0 , $ length = strlen ( $ text ) ; $ i < $ length ; ++ $ i ) { if ( $ delimiter == $ text { $ i } ) $...
Insert variables to the input from insertion array used the regexp constant of class
50,353
public static function reduce ( string $ text , string $ chars = ' ' ) : string { $ text = preg_replace ( '/[' . $ chars . ']{2,}/' , ' ' , $ text ) ; return $ text ; }
Clear multiply occurance of chars from text and leave only one
50,354
public function encode ( ) { return \ pack ( 'CCnnCx' , 1 , $ this -> getType ( ) -> value ( ) , $ this -> getRequestId ( ) , $ this -> getLength ( ) , $ this -> getPaddingLength ( ) ) ; }
Returns the encoded header as a string .
50,355
public function verify ( $ nonce , $ action ) { $ value = $ this -> Encryption -> decryptSecureCookie ( $ nonce ) ; if ( ! $ value ) return false ; if ( strcmp ( $ value , $ action ) === 0 ) return true ; return false ; }
Verifies the validity of a nonce against the supplied action .
50,356
public function create ( $ action ) { $ expire = time ( ) + $ this -> timePeriod ; $ user_id = $ this -> RequestContext -> getUserRef ( ) ; if ( is_null ( $ user_id ) ) $ user_id = $ this -> Session -> getID ( ) ; return $ this -> Encryption -> encryptSecureCookie ( strtolower ( $ action ) , $ expire , ( string ) $ use...
Creates a new nonce string for the given action typically derived from the user a salt and valid only for a given amount of time
50,357
public function reload ( ) { $ this -> init ( array ( self :: CONFIG_KEY_FILE_PATH => $ this -> getConfigFilePath ( ) , ConfigInterface :: KEY_CONTEXT => $ this -> getContext ( ) , ) ) ; }
Reload the configuration from file .
50,358
protected function doSetup ( $ config = array ( ) ) { if ( isset ( $ config [ self :: CONFIG_KEY_FILE_PATH ] ) ) { $ this -> configFilePath = $ config [ self :: CONFIG_KEY_FILE_PATH ] ; } else { return $ config ; } if ( isset ( $ config [ ConfigInterface :: KEY_CONTEXT ] ) ) { $ this -> context = $ config [ ConfigInter...
Override in child if you need to override core config setup .
50,359
public static final function jsonEncode ( $ data , array $ options = null ) : array { $ encoder = new JsonEncoder ( $ options ) ; return [ $ encoder -> encode ( $ data ) , $ encoder -> hasError ( ) ? new EncoderException ( 'JSON Error: ' . $ encoder -> getError ( ) ) : null ] ; }
Json encode .
50,360
public static final function jsonDecode ( $ data , array $ options = null ) : array { $ encoder = new JsonEncoder ( $ options ) ; return [ $ encoder -> decode ( $ data ) , $ encoder -> hasError ( ) ? new EncoderException ( 'JSON Error: ' . $ encoder -> getError ( ) ) : null ] ; }
Json decode .
50,361
public static final function gzipEncode ( $ data , array $ options = null ) : array { $ encoder = new GzipEncoder ( $ options ) ; return [ $ encoder -> encode ( $ data ) , $ encoder -> hasError ( ) ? new EncoderException ( 'GZip Error: ' . $ encoder -> getError ( ) ) : null ] ; }
Gzip encode .
50,362
public static final function gzipDecode ( $ data , array $ options = null ) : array { $ encoder = new GzipEncoder ( $ options ) ; return [ $ encoder -> decode ( $ data ) , $ encoder -> hasError ( ) ? new EncoderException ( 'GZip Error: ' . $ encoder -> getError ( ) ) : null ] ; }
Gzip decode .
50,363
protected function getOriginDb ( OutputInterface $ output , $ now ) { $ url = $ this -> getContainer ( ) -> getParameter ( 'anime_db.ani_db.import_titles' ) ; if ( ( $ path = parse_url ( $ url , PHP_URL_PATH ) ) === false ) { throw new \ InvalidArgumentException ( 'Failed parse URL: ' . $ url ) ; } $ fs = $ this -> get...
Get original db file .
50,364
public function addWithIndex ( $ index , $ element ) { if ( ! is_null ( $ index ) && is_scalar ( $ index ) ) { if ( ! $ this -> hasIndex ( $ index ) ) { $ this -> set ( $ index , $ element ) ; } else { throw new ListException ( 'Element could not be added to list. Index already exist.' , E_NOTICE ) ; } } else { throw n...
add a element to a specified position of the list
50,365
public function removeIndex ( $ index ) { if ( $ this -> hasIndex ( $ index ) ) { unset ( $ this -> _items [ $ index ] ) ; $ this -> _iterator = null ; return true ; } return false ; }
remove element with specified position from list
50,366
public function set ( $ index , $ element ) { if ( ! is_null ( $ index ) && is_scalar ( $ index ) ) { $ this -> _iterator = null ; return $ this -> _items [ $ index ] = $ element ; } else { throw new ListException ( 'Element could not be added to list. Index is not valid.' , E_NOTICE ) ; } }
add or replace a element to a specified position of the list
50,367
protected function getDefaultValidator ( ) : ValidatorInterface { $ loaders = [ new StaticMethodLoader ( ) ] ; if ( class_exists ( AnnotationReader :: class ) && class_exists ( ArrayCache :: class ) ) { AnnotationRegistry :: registerUniqueLoader ( 'class_exists' ) ; $ loaders [ ] = new AnnotationLoader ( new CachedRead...
Get a default validator .
50,368
protected function getRelationWhere ( $ links , $ key = null ) { if ( is_null ( $ key ) && ! is_array ( $ links ) ) { $ key = in_array ( 'id' , $ this -> primaryKey ) ? 'id' : reset ( $ this -> primaryKey ) ; } if ( ! is_array ( $ links ) ) { $ links = [ $ links => $ key ] ; } foreach ( $ links as & $ item ) { $ item =...
GET RELATION WHERE SQL
50,369
public function findManifests ( ) { foreach ( $ this -> src as $ component => $ source ) { $ src = $ source [ 0 ] . "/../manifest.php" ; if ( file_exists ( $ src ) && is_readable ( $ src ) ) { $ this -> manifests [ $ component ] = $ src ; } } }
Function is used to find manifests in psr4 loaded packages
50,370
protected function addGlobal ( string $ key , $ value ) { $ template = $ this -> getContext ( ) -> getTemplateEngine ( ) ; $ template -> addGlobal ( $ key , $ value ) ; }
Add a variable that will be globally accessible in the template
50,371
protected function getTemplateFile ( string $ action = null ) : string { $ path = '/controller/' . lcfirst ( $ this -> getControllerName ( ) ) . '/' ; return $ path . ( $ action ? $ action : $ this -> getActionName ( ) ) ; }
Returns the default template file
50,372
protected function isAjax ( ) : bool { $ header = $ this -> request -> getHeaders ( ) -> get ( 'X-Requested-With' ) ; if ( $ header === null ) { return false ; } return $ header -> getValue ( ) === 'XMLHttpRequest' ; }
Is the current request done with ajax?
50,373
protected function redirect ( $ controller = null , $ action = 'index' , array $ parameters = [ ] ) : Response { $ host = 'http://' . $ _SERVER [ 'HTTP_HOST' ] ; if ( $ controller === null ) { if ( $ action === 'index' ) { return $ this -> redirectUrl ( $ host ) ; } $ controller = $ this -> getControllerName ( ) ; } if...
Redirect to a controller
50,374
protected function hasPermission ( string $ permission , bool $ return = false ) { $ auth = $ this -> getContext ( ) -> getAuthentication ( ) ; $ user = $ auth -> getUser ( ) ; $ acl = $ this -> getContext ( ) -> getAccessControlList ( ) ; if ( ! $ acl -> hasAccess ( $ user , $ permission ) ) { if ( $ return ) { return...
Has the current user permission for the given action
50,375
public function createHttpClient ( $ name = '' , $ client = null ) { if ( empty ( $ name ) ) { return $ this -> createBestClient ( ) ; } if ( ! isset ( $ this -> classes [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The client "%s" is not registered.' , $ name ) ) ; } $ class = $ this -> classes [ ...
Generate the best http client according to the detected configuration
50,376
public function register ( $ name , $ class , $ requirement = '' , $ priority = false ) { if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s is not a valid class name.' , $ class ) ) ; } $ definition = [ 'class' => $ class , 'requirement' => $ requirement ] ; if ( $ priority ) { $ ...
Register a new client that will be able to be use by the ApiFactory
50,377
private function connect ( Credentials $ credentials ) : PDO { if ( $ this -> pdo === null ) { $ this -> pdo = new PDO ( $ credentials -> getDSN ( ) , $ credentials -> getUsername ( ) , $ credentials -> getPassword ( ) ) ; } return $ this -> pdo ; }
Makes the actual connection to the database
50,378
public static function process ( ArrayResolver $ config ) { $ copy = $ config -> extract ( ) ; $ instances = $ config -> resolveArray ( 'apply-templates' , [ ] ) ; foreach ( $ instances as $ name => $ instance ) { self :: processTemplate ( $ config , $ copy , $ name , $ instance ) ; } return new ArrayResolver ( $ copy ...
Processes a configuration node to expand the templates it contains .
50,379
public function getIcon ( ? string $ extension ) : ? string { $ iconClass = $ this -> iconSet [ $ this -> getIconType ( $ extension ) ] ?? null ; return $ iconClass !== null ? $ this -> iconPrefix . ' ' . $ iconClass : null ; }
Returns suitable css class for icon by extension .
50,380
public function getIconType ( ? string $ extension ) : string { if ( $ extension !== null && $ extension !== '' ) { foreach ( self :: TYPE_TO_REGEX as $ type => $ regex ) { if ( $ regex === null ) { continue ; } if ( ( $ regex === $ extension && preg_match ( '/[a-z0-9]+/' , $ extension ) ) || preg_match ( "/$regex/" , ...
Searches icon type by it s extension
50,381
public static function createRedirectFromPostValues ( $ postValues ) { if ( isset ( $ postValues [ 'title' ] , $ postValues [ 'fromUrl' ] , $ postValues [ 'toUrl' ] ) ) { $ redirectObject = new \ stdClass ( ) ; $ redirectObject -> title = $ postValues [ 'title' ] ; $ redirectObject -> slug = StringUtil :: slugify ( $ p...
Create a new redirect object from postvalues
50,382
public function clear ( ) { $ lastQuery = $ this -> query ; $ this -> query = new Query ( $ this -> error , $ lastQuery -> getInitializer ( ) ) ; $ this -> query -> forceLimit ( $ lastQuery -> getLimit ( ) ) ; $ this -> query -> forceOffset ( $ lastQuery -> getOffset ( ) ) ; if ( ! is_array ( $ lastQuery -> getResultDa...
Clear and reset persistence query .
50,383
public function setSingleQuery ( $ query ) { if ( $ this -> executed ) { $ this -> clear ( ) ; } $ this -> query -> single ( ) -> setQuery ( $ query ) ; return $ this ; }
Set Query to single statement executable .
50,384
public function setQuery ( $ queries ) { if ( $ this -> executed ) { $ this -> clear ( ) ; } $ this -> query -> multiple ( ) -> setQuery ( $ queries ) ; return $ this ; }
Set Query to multiple statement on next call this method will attach or append new query .
50,385
public function getAvailableDrivers ( ) { $ config = $ this -> client ? $ this -> client : $ this -> config ; return $ config -> getAvailableDrivers ( ) ; }
Get list of available drivers .
50,386
public function getServerVersion ( ) { if ( $ this -> client ) { return $ this -> client -> getServerVersion ( ) ; } $ connection = new Connection ( $ this -> config ) ; return $ connection -> getAttribute ( \ PDO :: ATTR_SERVER_VERSION ) ; }
Get current version of database platform .
50,387
public function run ( ) { $ this -> executed = true ; if ( $ this -> client instanceof ClientInterface ) { $ this -> client -> sendRequest ( ) ; } else { $ connection = new Connection ( $ this -> config ) ; $ executor = new Executor ( $ connection ) ; $ executor -> execQuery ( $ this -> query ) ; } return $ this -> has...
Run and execute prepared sql queries .
50,388
public function getResult ( $ resultMode = 0 ) { switch ( $ resultMode ) { case self :: FETCH_ARRAY : return $ this -> query -> toArray ( ) ; break ; case self :: FETCH_JSON : $ result = json_encode ( $ this -> query -> toArray ( ) ) ; return $ result ; break ; case self :: FETCH_JSON_BEAUTIFY : $ result = json_encode ...
Get Result .
50,389
public static function createService ( $ serviceName ) { switch ( $ serviceName ) { case self :: SERVICE_REST : return new RestService ( ) ; break ; case self :: SERVICE_SOAP : return new SoapService ( ) ; break ; case self :: SERVICE_XMLRPC : return new XmlRpcService ( ) ; break ; } throw new \ Exception ( sprintf ( '...
Create Service .
50,390
protected function getMappingClasses ( ) : array { AnnotationRegistry :: registerLoader ( 'class_exists' ) ; $ mappingClasses = [ ] ; foreach ( $ this -> locator -> getMappingFiles ( ) as $ annotationFile ) { $ mappingClasses [ ] = $ this -> loadClassFromFile ( $ annotationFile ) ; } return \ array_map ( function ( str...
Get mapping classes .
50,391
protected function loadClassFromFile ( string $ annotationFile ) : string { $ tokens = \ token_get_all ( \ file_get_contents ( $ annotationFile ) ) ; $ hasClass = false ; $ class = null ; $ hasNamespace = false ; $ namespace = '' ; for ( $ i = 0 , $ length = \ count ( $ tokens ) ; $ i < $ length ; $ i ++ ) { $ token = ...
Load fully qualified class name from file .
50,392
public function logChange ( $ args ) { if ( ! isset ( $ args [ "code" ] ) || ! is_numeric ( $ args [ "code" ] ) ) { if ( isset ( $ this -> AUDIT_CODE ) ) { $ args [ "code" ] = $ this -> AUDIT_CODE ; } else { return false ; } } if ( ! isset ( $ args [ "data" ] ) || '[]' == $ args [ "data" ] ) { return false ; } $ query ...
Log an entity change
50,393
public function tempnam ( ) { $ sysTempDir = $ this -> _sysGetTempDir ( ) ; do { $ this -> _tempnamCounter ++ ; $ name = $ sysTempDir . "/" . $ this -> _tempnamCounter ; } while ( file_exists ( $ name ) ) ; return $ name ; }
Return unique filename
50,394
private function _sysGetTempDir ( $ create = true ) { if ( is_null ( $ this -> _systemTempDirectory ) && $ create ) { $ sysTmpDir = rtrim ( sys_get_temp_dir ( ) , "\\/" ) ; do { $ name = $ sysTmpDir . "/" . uniqid ( "fs" , true ) ; } while ( file_exists ( $ name ) ) ; mkdir ( $ name , 0777 ) ; $ this -> _systemTempDire...
Return path to own temp directory
50,395
public function constructFromTable ( $ table , $ data ) { $ this -> _database = $ table -> getDatabase ( ) ; $ this -> _table = $ table ; $ this -> _parseName ( $ data ) ; $ this -> _parseDatatype ( $ data ) ; $ this -> _parseNotnull ( $ data ) ; $ this -> _parseDefault ( $ data ) ; $ this -> _parseAutoIncrement ( $ da...
Internal method to set up the object from within a \ Nada \ Table \ AbstractTable object
50,396
public function toArray ( ) { return array ( 'name' => $ this -> _name , 'type' => $ this -> _datatype , 'length' => $ this -> _length , 'notnull' => $ this -> _notnull , 'default' => $ this -> _default , 'autoincrement' => $ this -> _autoIncrement , 'comment' => $ this -> _comment , ) ; }
Export column data to an associative array
50,397
protected function _parseNotnull ( $ data ) { switch ( $ data [ 'is_nullable' ] ) { case 'YES' : $ this -> _notnull = false ; break ; case 'NO' : $ this -> _notnull = true ; break ; default : throw new \ UnexpectedValueException ( 'Invalid yes/no type: ' . $ data [ 'is_nullable' ] ) ; } }
Extract NOT NULL constraint from column data
50,398
public function setName ( $ name ) { if ( strlen ( $ name ) == 0 ) { throw new \ InvalidArgumentException ( 'Column name must not be empty' ) ; } if ( $ this -> _table ) { $ this -> _table -> renameColumn ( $ this , $ name ) ; } $ this -> _name = $ name ; }
Change the column s name
50,399
protected function _setDefault ( ) { if ( $ this -> _default === null ) { $ this -> _table -> alter ( sprintf ( 'ALTER COLUMN %s DROP DEFAULT' , $ this -> _database -> prepareIdentifier ( $ this -> _name ) ) ) ; } else { $ this -> _table -> alter ( sprintf ( 'ALTER COLUMN %s SET DEFAULT %s' , $ this -> _database -> pre...
DBMS - specific implementation for setting a column s default value