idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
10,200
public function redirect ( $ to ) { if ( is_array ( $ to ) ) { $ to = join ( '/' , $ to ) ; } $ uri = $ this -> base_uri ; if ( 'http://' != substr ( $ to , 0 , 7 ) && 'https://' != substr ( $ to , 0 , 8 ) ) { if ( $ to [ 0 ] != '/' && $ uri [ strlen ( $ uri ) - 1 ] != '/' ) { $ to = '/' . $ to ; } $ to = join ( '' , [...
Redirects to another module with an HTTP redirect
10,201
public function handle ( Request $ request , Closure $ next , $ requestKey = 'default' ) { if ( ! array_key_exists ( $ requestKey , $ this -> configurations -> get ( 'signed-requests' ) ) ) { throw new InvalidConfigurationException ( ) ; } $ signed = new Verifier ( $ request ) ; $ key = sprintf ( '%s.%s' , $ this -> co...
Applies the middleware to the request before moving onto the next request handler .
10,202
public function getExtrasDDLWithDelimiter ( ) { $ ddls = $ this -> getExtrasDDL ( ) ; $ start = "DELIMITER {$this->delimiter}" ; $ end = 'DELIMITER ;' ; $ newDdls = [ ] ; foreach ( $ ddls as $ idx => $ ddl ) { $ newDdls [ ] = $ start ; if ( ! preg_match ( '/;$/' , $ ddl ) ) { $ newDdls [ ] = $ ddl . ' ' . $ this -> del...
Special case for Mysql when delaing with delimiters .
10,203
public function getTitle ( ) { $ title = ( $ this -> Title ) ? $ this -> Title : sprintf ( 'Delete %s %s' , count ( $ this -> ids ) , $ this -> dataClass ) ; if ( $ this -> User ) { return $ title .= sprintf ( ' (Initiated by %s)' , $ this -> User -> getTitle ( ) ) ; } return $ title ; }
Defines the title of the job
10,204
public function process ( ) { $ remainingChildren = $ this -> remainingChildren ; if ( ! count ( $ remainingChildren ) ) { $ this -> isComplete = true ; $ this -> handleCompletion ( ) ; return ; } $ class = $ this -> dataClass ; $ ID = array_shift ( $ remainingChildren ) ; $ record = null ; if ( class_exists ( 'Subsite...
Lets process one ID at the time
10,205
public function handleCompletion ( ) { $ member = $ this -> User ; if ( $ member && $ member -> exists ( ) ) { $ email = new Email ( ) ; $ email -> setTo ( $ member -> Email ) ; $ email -> setSubject ( 'A deletion task requested by you has completed.' ) ; $ message = sprintf ( '<p>Hi, %s</p>' , $ member -> getTitle ( )...
Send an email to the supplied user upon completion
10,206
public function checkBonusEntry ( $ game , $ user ) { $ query = $ this -> em -> createQuery ( 'SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e WHERE e.user = :user AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL)' ) ; $ query -> setParameter ( 'user' , $ user ) ; $ query -> setParameter ( 'gam...
Compte les nombre de participations bonus
10,207
public function add ( $ title , $ url = null , array $ options = [ ] ) { $ options = optionsParser ( $ options ) -> append ( 'class' , 'breadcrumb-item' ) ; return parent :: add ( $ title , $ url , $ options -> toArray ( ) ) ; }
Add a crumb to the end of the trail
10,208
public function render ( array $ attributes = [ ] , array $ separator = [ ] ) { if ( empty ( $ this -> crumbs ) ) { return parent :: render ( $ attributes , $ separator ) ; } end ( $ this -> crumbs ) ; $ last = key ( $ this -> crumbs ) ; $ this -> crumbs [ $ last ] [ 'url' ] = null ; $ attributes = optionsParser ( $ at...
Renders the breadcrumbs trail
10,209
protected function doHardBreaks ( $ text ) { if ( $ this -> single_linebreak == true ) { $ expression = '/ {2,}\n|\n{1}/' ; } else { $ expression = '/ {2,}\n/' ; } return preg_replace_callback ( $ expression , array ( & $ this , '_doHardBreaks_callback' ) , $ text ) ; }
Override method doHardBreaks
10,210
public function initializeObject ( ) { if ( $ this -> browserRequestEngine instanceof DependencyProxy ) { $ this -> browserRequestEngine -> _activateDependency ( ) ; } $ this -> browser -> setRequestEngine ( $ this -> browserRequestEngine ) ; }
Initialize this service
10,211
public function isCommentSpam ( $ permaLink , $ content , $ type , $ author = '' , $ authorEmailAddress = '' , $ authorUri = '' ) { if ( $ this -> settings [ 'apiKey' ] === '' || $ this -> settings [ 'apiKey' ] === null ) { $ this -> systemLogger -> log ( 'Could not check comment for spam because no Akismet API key was...
Checks if the given comment is considered spam by the service .
10,212
public function submitSpam ( $ permaLink , $ content , $ type , $ author = '' , $ authorEmailAddress = '' , $ authorUri = '' ) { if ( $ this -> settings [ 'apiKey' ] === '' ) { $ this -> systemLogger -> log ( 'Could not submit new spam sample to Akismet because no API key was provided in the settings.' , LOG_WARNING ) ...
Submits missed spam comment which hasn t been recognized .
10,213
public function left ( $ text , $ length ) { if ( ! $ this -> isValidLength ( $ text , $ length ) ) return $ text ; return \ substr ( $ text , 0 , $ length ) ; }
Returns the left part of a string according the given length
10,214
public function right ( $ text , $ length ) { if ( ! $ this -> isValidLength ( $ text , $ length ) ) return $ text ; $ textLength = strlen ( $ text ) ; return \ substr ( $ text , $ textLength - $ length , $ textLength ) ; }
Returns the right part of a string according the given length
10,215
public function truncate ( $ text , $ length = 15 ) { if ( ! $ this -> isValidLength ( $ text , $ length ) ) return $ text ; return ( \ strlen ( $ text ) > $ length ) ? $ this -> left ( $ text , $ length ) . '...' : $ text ; }
Truncates the string at the given length
10,216
protected function embedImage ( \ Swift_Message $ message , \ DOMAttr $ node , array & $ images ) : void { if ( 0 === strpos ( $ node -> nodeValue , 'cid:' ) ) { return ; } if ( isset ( $ images [ $ node -> nodeValue ] ) ) { $ node -> nodeValue = $ images [ $ node -> nodeValue ] ; } else { $ node -> nodeValue = EmbedIm...
Embed the image in message and replace the image link by attachment id .
10,217
public function getEntityContainerIterator ( ) { if ( is_null ( $ this -> entityContainerIterator ) ) { $ this -> entityContainerIterator = new Iterator ( $ this -> getEntityContainerMap ( ) -> getAll ( ) ) ; } return $ this -> entityContainerIterator ; }
Iterator for entity container map
10,218
protected function validateSynchronizerToken ( array $ payload = null ) { if ( $ this -> configuration -> get ( 'csrf_protection' ) ) { if ( ! is_null ( $ payload ) && isset ( $ payload [ $ this -> configuration -> get ( 'csrf_parameter' ) ] ) ) { $ this -> logger -> debug ( 'validate synchronizer token' , array ( 'nam...
return if given synchronizer token is valid
10,219
protected function validate ( ) { if ( ! $ this -> validator instanceof ValidatorInterface ) { return ; } $ valid = true ; if ( $ this -> getEntityContainerMap ( ) -> count ( ) > 0 ) { $ entityContainers = $ this -> getEntityContainerMap ( ) -> getAll ( ) ; $ this -> logger -> debug ( 'start form entity valiation' , ar...
validate bind data
10,220
protected function attachEntityContainer ( EntityContainerInterface $ entityContainer ) { $ this -> getEntityContainerMap ( ) -> set ( $ entityContainer -> getName ( ) , $ entityContainer ) ; $ this -> resetEntityIterator ( ) ; }
add form entity container to entity map
10,221
public function attachEntities ( array $ entities ) { foreach ( $ entities as $ name => $ entitie ) { $ this -> attachEntity ( $ entitie , $ name ) ; } }
add array of entities
10,222
public static function byId ( Client $ client , int $ id ) : self { $ posts = self :: search ( $ client , [ 'id:' . $ id ] , 1 , 1 ) ; if ( count ( $ posts ) === 0 ) { throw new PostNotFoundException ( sprintf ( 'Post with ID %d not found' , $ id ) ) ; } return $ posts [ 0 ] ; }
Get certain post by its ID or throw exception if nothing found .
10,223
protected static function fromArray ( Client $ client , array $ post ) : self { $ originalFile = isset ( $ post [ 'file_ext' ] ) ? File :: fromArray ( $ post ) : null ; $ tags = Tag :: byNames ( $ client , explode ( ' ' , $ post [ 'tag_string' ] ) ) ; return new self ( $ post [ 'id' ] , DateTimeImmutable :: createFromF...
Creates Post instance from API response .
10,224
protected static function getRatingByStringIdentifier ( string $ identifier ) : int { switch ( $ identifier ) { case 's' : return PostInterface :: RATING_SAFE ; case 'q' : return PostInterface :: RATING_QUESTIONABLE ; case 'e' : return PostInterface :: RATING_EXPLICIT ; default : throw new InvalidArgumentException ( 'U...
Converts API rating identifier to constant value .
10,225
protected static function getStatusByBooleanFlags ( bool $ isPending , bool $ isDeleted , bool $ isBanned ) : int { if ( $ isBanned === true ) { return PostInterface :: STATUS_DELETED ; } if ( $ isDeleted === true ) { return PostInterface :: STATUS_DELETED ; } if ( $ isPending === true ) { return PostInterface :: STATU...
Returns constant value by post status flags .
10,226
public static function generateMetadataHeaders ( array $ metadata , $ prefix = NULL ) { if ( empty ( $ prefix ) ) { $ prefix = Container :: METADATA_HEADER_PREFIX ; } $ headers = array ( ) ; foreach ( $ metadata as $ key => $ val ) { $ headers [ $ prefix . $ key ] = $ val ; } return $ headers ; }
Transform a metadata array into headers .
10,227
public static function objectUrl ( $ base , $ oname ) { if ( strpos ( $ oname , '/' ) === FALSE ) { return $ base . '/' . rawurlencode ( $ oname ) ; } $ oParts = explode ( '/' , $ oname ) ; $ buffer = array ( ) ; foreach ( $ oParts as $ part ) { $ buffer [ ] = rawurlencode ( $ part ) ; } $ newname = implode ( '/' , $ b...
Create an object URL .
10,228
public static function extractHeaderAttributes ( $ headers , $ prefix = NULL ) { if ( empty ( $ prefix ) ) { $ prefix = Container :: METADATA_HEADER_PREFIX ; } $ attributes = array ( ) ; $ offset = strlen ( $ prefix ) ; foreach ( $ headers as $ header => $ value ) { $ index = strpos ( $ header , $ prefix ) ; if ( $ ind...
Extract object attributes from HTTP headers .
10,229
public static function newFromJSON ( $ jsonArray , $ token , $ url ) { $ container = new Container ( $ jsonArray [ 'name' ] ) ; $ container -> baseUrl = $ url ; $ container -> url = $ url . '/' . rawurlencode ( $ jsonArray [ 'name' ] ) ; $ container -> token = $ token ; if ( ! empty ( $ jsonArray [ 'count' ] ) ) { $ co...
Create a new Container from JSON data .
10,230
public static function newFromResponse ( $ name , $ response , $ token , $ url ) { $ container = new Container ( $ name ) ; $ container -> bytes = $ response -> header ( 'X-Container-Bytes-Used' , 0 ) ; $ container -> count = $ response -> header ( 'X-Container-Object-Count' , 0 ) ; $ container -> baseUrl = $ url ; $ c...
Given an OpenStack HTTP response build a Container .
10,231
public function save ( Object $ obj , $ file = NULL ) { if ( empty ( $ this -> token ) ) { throw new \ HPCloud \ Exception ( 'Container does not have an auth token.' ) ; } if ( empty ( $ this -> url ) ) { throw new \ HPCloud \ Exception ( 'Container does not have a URL to send data.' ) ; } $ url = self :: objectUrl ( $...
Save an Object into Object Storage .
10,232
public function updateMetadata ( Object $ obj ) { $ url = self :: objectUrl ( $ this -> url , $ obj -> name ( ) ) ; $ headers = array ( ) ; $ md = $ obj -> metadata ( ) ; if ( ! empty ( $ md ) ) { $ headers = self :: generateMetadataHeaders ( $ md , Container :: METADATA_HEADER_PREFIX ) ; } $ headers [ 'X-Auth-Token' ]...
Update an object s metadata .
10,233
public function copy ( Object $ obj , $ newName , $ container = NULL ) { $ sourceUrl = self :: objectUrl ( $ this -> url , $ obj -> name ( ) ) ; if ( empty ( $ newName ) ) { throw new \ HPCloud \ Exception ( "An object name is required to copy the object." ) ; } if ( empty ( $ container ) ) { $ container = $ this -> na...
Copy an object to another place in object storage .
10,234
public function object ( $ name , $ requireSSL = TRUE ) { $ url = self :: objectUrl ( $ this -> url , $ name ) ; $ cdn = self :: objectUrl ( $ this -> cdnUrl , $ name ) ; $ cdnSsl = self :: objectUrl ( $ this -> cdnSslUrl , $ name ) ; $ headers = array ( ) ; $ headers [ 'X-Auth-Token' ] = $ this -> token ; $ client = \...
Get the object with the given name .
10,235
public function proxyObject ( $ name ) { $ url = self :: objectUrl ( $ this -> url , $ name ) ; $ cdn = self :: objectUrl ( $ this -> cdnUrl , $ name ) ; $ cdnSsl = self :: objectUrl ( $ this -> cdnSslUrl , $ name ) ; $ headers = array ( 'X-Auth-Token' => $ this -> token , ) ; $ client = \ HPCloud \ Transport :: instan...
Fetch an object but delay fetching its contents .
10,236
public function objects ( $ limit = NULL , $ marker = NULL ) { $ params = array ( ) ; return $ this -> objectQuery ( $ params , $ limit , $ marker ) ; }
Get a list of objects in this container .
10,237
public function objectsWithPrefix ( $ prefix , $ delimiter = '/' , $ limit = NULL , $ marker = NULL ) { $ params = array ( 'prefix' => $ prefix , 'delimiter' => $ delimiter , ) ; return $ this -> objectQuery ( $ params , $ limit , $ marker ) ; }
Retrieve a list of Objects with the given prefix .
10,238
protected function loadExtraData ( ) { if ( empty ( $ this -> url ) || empty ( $ this -> token ) ) { throw new \ HPCloud \ Exception ( 'Remote data cannot be fetched. Tokena and endpoint URL are required.' ) ; } $ client = \ HPCloud \ Transport :: instance ( ) ; $ headers = array ( 'X-Auth-Token' => $ this -> token , )...
Get missing fields .
10,239
protected function objectQuery ( $ params = array ( ) , $ limit = NULL , $ marker = NULL ) { if ( isset ( $ limit ) ) { $ params [ 'limit' ] = ( int ) $ limit ; if ( ! empty ( $ marker ) ) { $ params [ 'marker' ] = ( string ) $ marker ; } } $ params [ 'format' ] = 'json' ; $ query = http_build_query ( $ params ) ; $ qu...
Perform the HTTP query for a list of objects and de - serialize the results .
10,240
public function delete ( $ name ) { $ url = self :: objectUrl ( $ this -> url , $ name ) ; $ headers = array ( 'X-Auth-Token' => $ this -> token , ) ; $ client = \ HPCloud \ Transport :: instance ( ) ; try { $ response = $ client -> doRequest ( $ url , 'DELETE' , $ headers ) ; } catch ( \ HPCloud \ Transport \ FileNotF...
Remove the named object from storage .
10,241
public function setType ( ? string $ type ) : self { if ( ! $ this -> isValidType ( $ type ) ) { throw new \ InvalidArgumentException ( \ sprintf ( "Invalid type '%s'. Must be either NULL, one of %s, or a fully qualified class name or interface" , $ type , \ implode ( ', ' , $ this -> getValidTypes ( ) ) ) ) ; } $ this...
Sets the type all elements in the collection must be . Can be a primitive type class name or interface .
10,242
public function validate ( $ element ) : bool { if ( ! $ expectedType = $ this -> getType ( ) ) { return true ; } $ expectedType = $ this -> typeMap [ $ expectedType ] ?? $ expectedType ; $ actualType = \ gettype ( $ element ) ; if ( ( $ actualType === 'object' && $ element instanceof $ expectedType ) || $ actualType =...
Returns whether the given element is a valid type .
10,243
protected function getItemKeyByEventId ( Identifier $ eventId , array $ context = [ ] ) : ? array { $ tableName = $ this -> getTableNameForRead ( $ context ) ; $ params = [ 'TableName' => $ tableName , 'IndexName' => EventStoreTable :: GSI_EVENT_ID_NAME , 'Limit' => 1 , 'ExpressionAttributeNames' => [ '#hash' => EventS...
When needing to get or delete an event by its id we must first get the DynamoDb item key from the GSI . At this time DynamoDb does not support a batch get from a GSI so this can only handle one event id at a time .
10,244
protected function optimisticCheck ( StreamId $ streamId , string $ expectedEtag , array $ context ) : void { $ slice = $ this -> getStreamSlice ( $ streamId , null , 1 , false , true , $ context ) ; if ( ! $ slice -> count ( ) ) { throw new OptimisticCheckFailed ( sprintf ( 'The DynamoDb table [%s] has no events in st...
When an expected etag is provided we can check the head of the stream to see if it s at the expected state before appending events .
10,245
public function verbose ( $ verbose = null ) { if ( $ verbose !== null ) { $ this -> details = ( bool ) $ verbose ; } return $ this -> details ; }
Sets reporting details
10,246
public function depthLimit ( $ depthLimit = null ) { if ( $ depthLimit !== null ) { $ this -> depthLimit = ( int ) $ depthLimit ; } return $ this -> depthLimit ; }
Sets depth limit
10,247
public function handlerTerse ( \ Exception $ exception ) { if ( ! headers_sent ( ) ) { header ( 'HTTP/1.1 500 Internal Server Error' , true , 500 ) ; header ( 'Content-type: text/plain; charset=UTF-8' ) ; } echo sprintf ( 'Bad Moss: %s ( %s at line: %u )' , $ exception -> getMessage ( ) , $ exception -> getFile ( ) , $...
Terse exception handler Sends only simplified exception message in plain text
10,248
public function handlerVerbose ( \ Exception $ exception ) { if ( ! headers_sent ( ) ) { header ( 'HTTP/1.1 500 Internal Server Error' , true , 500 ) ; header ( 'Content-type: text/html; charset=UTF-8' ) ; } echo sprintf ( '<!DOCTYPE html> <html> <head> <title>Bad Moss: %1$s - %2$s - %3$s:%4$u<...
Verbose exception handler Sends HTML message with file where error occurred and stack trace
10,249
public function lineNumbers ( $ lineSeparator , $ source , $ mark = null ) { $ count = count ( explode ( $ lineSeparator , $ source ) ) ; $ tpl = '<span %s>%u</span>' ; $ lines = [ ] ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ lines [ ] = sprintf ( $ tpl , '' , $ i + 1 ) ; } $ lines [ $ mark - 1 ] = sprintf ( $ tpl ...
Adds line numbers
10,250
public function limit ( $ var , $ depth , array & $ references = [ ] ) { if ( $ depth > $ this -> depthLimit ) { return '*DEPTH LIMIT*' ; } if ( is_array ( $ var ) ) { return $ this -> limitArray ( $ var , $ depth , $ references ) ; } if ( is_object ( $ var ) ) { return $ this -> limitObject ( $ var , $ depth , $ refer...
Limits dumped variable
10,251
public function limitArray ( $ var , $ depth , array & $ references ) { foreach ( $ var as & $ value ) { $ value = $ this -> limit ( $ value , $ depth + 1 , $ references ) ; unset ( $ value ) ; } return $ var ; }
Limits dumped array
10,252
public function limitObject ( $ var , $ depth , array & $ references ) { $ hash = spl_object_hash ( $ var ) ; if ( in_array ( $ hash , $ references ) ) { return '*RECURSION*' ; } $ references [ ] = $ hash ; $ ref = new \ ReflectionObject ( $ var ) ; foreach ( $ ref -> getProperties ( ) as $ prop ) { $ prop -> setAccess...
Limits dumped object
10,253
private function copy ( ) { $ source = Yii :: getAlias ( $ this -> source ) ; if ( ! file_exists ( $ source ) || ! is_dir ( $ source ) ) { throw new ErrorException ( "Source directory {$this->source} not found" ) ; } $ destination = Yii :: getAlias ( $ this -> destination ) ; if ( ! $ this -> replace && is_dir ( $ dest...
Copies original module files to destination folder .
10,254
private function replace ( ) { $ destination = Yii :: getAlias ( $ this -> destination ) ; $ destinationModuleName = $ this -> getDestinationModuleName ( ) ; $ counter = 0 ; $ files = FileHelper :: findFiles ( $ destination ) ; asort ( $ files ) ; foreach ( $ files as $ path ) { if ( ! $ this -> replace && in_array ( $...
Replaces all new module classes content with empty template .
10,255
protected function call ( $ eventName , $ subject = null , $ message = null ) { if ( ! isset ( $ this -> events [ $ eventName ] ) ) { return $ subject ; } foreach ( $ this -> events [ $ eventName ] as $ listener ) { if ( $ this -> stop ) { break ; } $ subject = $ listener ( $ this -> container , $ subject , $ message ,...
Calls event listener
10,256
public static function wrap ( $ bean , $ modelClass = null ) { if ( is_array ( $ bean ) ) { $ collection = new Collection ( $ bean ) ; $ collection -> map ( function ( $ item ) use ( $ modelClass ) { if ( $ modelClass ) { return new $ modelClass ( $ item ) ; } else { return new static ( $ item ) ; } } ) ; return $ coll...
Converts an OODBBean to Model
10,257
public static function dispense ( $ num = 1 , $ alwaysReturnArray = false ) { $ bean = DB :: dispense ( static :: getTable ( ) , $ num , $ alwaysReturnArray ) ; $ model = static :: wrap ( $ bean ) ; return $ model ; }
Dispenses this bean
10,258
public static function findLike ( $ like = [ ] , $ sql = '' ) { $ items = DB :: findLike ( static :: getTable ( ) , $ like , $ sql ) ; return static :: wrap ( $ items ) ; }
Tries to find beans matching the specified type and criteria set .
10,259
public static function findCollection ( $ sql = null , $ bindings = [ ] ) { $ collection = DB :: findCollection ( static :: getTable ( ) , $ sql , $ bindings ) ; return new BeanCollection ( $ collection ) ; }
Finds a BeanCollection using the repository . A bean collection can be used to retrieve one bean at a time using cursors - this is useful for processing large datasets . A bean collection will not load all beans into memory all at once just one at a time .
10,260
public function save ( ) { $ this -> setDefaultProperties ( ) ; $ this -> updateTimestamps ( ) ; if ( ! $ this -> fireBeforeSaveEvent ( $ this ) ) { return false ; } $ updating = $ this -> exists ( ) ; if ( $ updating && ! $ this -> fireBeforeUpdateEvent ( $ this ) ) { return false ; } elseif ( ! $ this -> fireBeforeCr...
Stores a bean in the database . If the database schema is not compatible with this bean and RedBean runs in fluid mode the schema will be altered to store the bean correctly . If the database schema is not compatible with this bean and RedBean runs in frozen mode it will throw an exception . This function returns the p...
10,261
public function trash ( ) { if ( $ this -> fireBeforeTrashEvent ( $ this ) ) { $ result = DB :: trash ( $ this -> bean ) ; $ this -> fireAfterTrashEvent ( $ result ) ; return true ; } else { return false ; } }
Removes this bean from the database .
10,262
public function owns ( $ related , $ exclusive = true ) { $ table = ucfirst ( $ related :: getTable ( ) ) ; $ column = ( $ exclusive ? 'x' : '' ) . "own{$table}List" ; $ this -> bean -> $ column [ ] = $ related -> getBean ( ) ; }
Create one - to - many relationship
10,263
public function hasMany ( Model $ related ) { $ table = ucfirst ( $ related -> getTable ( ) ) ; $ column = "shared{$table}List" ; $ this -> bean -> $ column [ ] = $ related -> getBean ( ) ; }
Create many - to - many relationship
10,264
public function getMany ( $ relatedClass ) { $ table = ucfirst ( $ relatedClass :: getTable ( ) ) ; $ column = "shared{$table}List" ; return static :: wrap ( $ this -> bean -> $ column , $ relatedClass ) ; }
Get many - to - many relationship
10,265
public function belongsTo ( $ related , $ foreignKey = '' ) { if ( ! $ foreignKey && $ related instanceof Model ) { $ column = $ related -> getTable ( ) ; } else { $ column = $ foreignKey ; } if ( empty ( $ related ) ) { unset ( $ this -> bean -> $ column ) ; } elseif ( $ related instanceof Model ) { $ this -> bean -> ...
Create reverse one - to - many relationship
10,266
public function getOwner ( $ relatedClass , $ foreignKey = '' ) { if ( ! $ foreignKey ) { $ column = $ relatedClass :: getTable ( ) ; } else { $ column = $ foreignKey ; } return static :: wrap ( $ this -> fetchAs ( $ relatedClass ) -> $ column , $ relatedClass ) ; }
Get one - to - many relationship
10,267
private function runHandlers ( $ event , $ data = null ) { foreach ( $ this -> handlers [ $ event ] as $ handler ) { if ( ! is_callable ( $ handler ) ) { return false ; } if ( ! $ handler ( $ data ) ) { return false ; } } return true ; }
Runs the handlers for the given event
10,268
protected function addHandler ( $ event , callable $ handler ) { if ( ! isset ( $ this -> handlers [ $ event ] ) ) { throw new Exception ( "No such event '$event'" ) ; } if ( ! is_callable ( $ handler ) ) { throw new Exception ( "Event handlers must be callable" ) ; } $ this -> handlers [ $ event ] [ ] = $ handler ; re...
Adds a handler for the given event
10,269
protected function removeHandler ( $ event , $ key ) { if ( $ this -> hasHandler ( $ event , $ key ) ) { unset ( $ this -> handlers [ $ event ] [ $ key ] ) ; } }
Removes the handle with the given event key
10,270
public static function isAttributeChanged ( Event $ event , $ attribute ) { $ sender = $ event -> sender ; if ( ! isset ( $ event -> changedAttributes ) ) { return $ sender -> isAttributeChanged ( $ attribute ) ; } return isset ( $ event -> changedAttributes [ $ attribute ] ) ; }
Checks whether event sender attribute is changed .
10,271
private function ensureCorrectColumnType ( ) { if ( ! $ this -> database -> tableExists ( 'tl_metamodel_attribute' ) ) { return ; } $ attributes = $ this -> database -> prepare ( 'SELECT metamodel.tableName, attribute.colname FROM tl_metamodel_attribute AS attribute LEFT JOIN tl_metamodel ...
Ensure that the column types are correct .
10,272
public function getContainerExtension ( ) { if ( null === $ this -> extension || false === $ this -> extension ) { $ this -> extension = new GendoriaCommandQueueExtension ( ) ; } return $ this -> extension ; }
Get default extension class instance .
10,273
public function prepare ( Exception $ exception ) { if ( $ exception instanceof NotFoundHttpException ) { return $ exception -> createsClientError ( ) ; } else if ( $ exception instanceof ServiceUnavailableHttpException ) { return $ exception -> createsServerError ( ) ; } return $ exception ; }
Prepare and convert exceptions
10,274
public function destroy ( ) { unset ( $ this -> storage ) ; $ _SESSION = [ ] ; session_destroy ( ) ; $ this -> startSession ( ) ; $ this -> storage = & $ _SESSION ; return $ this ; }
Clears all session data and regenerates session ID
10,275
protected function getRules ( ) { $ result = [ ] ; $ relationNames = [ ] ; foreach ( $ this -> relations as $ key => $ value ) { $ relationNames [ ] = is_array ( $ value ) ? $ key : $ value ; } foreach ( $ this -> owner -> rules ( ) as $ key => $ rule ) { $ attributes = is_array ( $ rule [ 0 ] ) ? $ rule [ 0 ] : [ $ ru...
Extracts rules for relations only .
10,276
public function getTargetController ( ) { $ target = $ this -> getTarget ( ) ; if ( $ target instanceof Closure || ! preg_match ( Router :: TARGET_REGEX , $ target ) ) { return null ; } $ parts = explode ( '@' , $ target ) ; return isset ( $ parts [ 0 ] ) ? $ parts [ 0 ] : null ; }
Gets the matched controller class
10,277
public function setRouteURI ( $ routeURI ) { $ groupPrefix = implode ( '/' , Router :: $ groupsProps [ 'prefix' ] ) ; if ( $ groupPrefix ) { $ prefixed = trim ( preg_replace ( '/\/+/' , '/' , $ groupPrefix ) , '/' ) ; $ routeURI = $ prefixed . '/' . trim ( $ routeURI , '/' ) ; } if ( $ routeURI ) { $ this -> routeURI =...
Sets URI for this route
10,278
public function setTarget ( $ target ) { if ( ! $ target instanceof \ Closure ) { $ groupNamespace = implode ( '\\' , Router :: $ groupsProps [ 'namespace' ] ) ; $ target = $ groupNamespace ? "$groupNamespace\\$target" : $ target ; } if ( ! $ target instanceof Closure && ! preg_match ( Router :: TARGET_REGEX , $ target...
Sets the target controller or closure for this route
10,279
public function setName ( $ name ) { if ( $ this -> lock ) { throw new Exception ( 'Route cannot be modified' ) ; } if ( empty ( $ name ) ) { return $ name ; } $ groupName = implode ( '' , Router :: $ groupsProps [ 'name' ] ) ; $ this -> name = $ groupName . $ name ; Router :: getInstance ( ) -> registerNamedRoute ( $ ...
Sets the name of this route and registers it in the Router
10,280
public function setMiddleware ( $ middleware ) { if ( $ this -> lock ) { throw new Exception ( 'Route cannot be modified' ) ; } $ curMiddleware = [ ] ; if ( is_array ( $ middleware ) ) { $ curMiddleware = $ middleware ; } else { $ args = func_get_args ( ) ; foreach ( $ args as $ arg ) { if ( is_string ( $ arg ) ) { $ c...
Sets middleware for this route
10,281
public function getOpenId ( AccessToken $ token ) { $ request = $ this -> getAuthenticatedRequest ( self :: METHOD_GET , $ this -> domain . '/oauth2.0/me?access_token=' . ( string ) $ token ) ; $ response = $ this -> getResponse ( $ request ) ; return isset ( $ response [ 'openid' ] ) ? $ response [ 'openid' ] : null ;...
Get open id from access token
10,282
public function getResourceOwner ( AccessToken $ token ) { $ this -> openId = $ this -> getOpenId ( $ token ) ; return parent :: getResourceOwner ( $ token ) ; }
Requests and returns the resource owner of given access token .
10,283
public function parser ( $ text ) { $ methods = array_diff ( get_child_methods ( get_class ( ) ) , [ 'parser' , 'remove' ] ) ; foreach ( $ methods as $ method ) { $ text = call_user_func ( [ $ this , $ method ] , $ text ) ; } return $ text ; }
Executes all parsers
10,284
public function youtube ( $ text ) { return preg_replace_callback ( $ this -> pattern [ 'youtube' ] , function ( $ matches ) { $ id = is_url ( $ matches [ 1 ] ) ? Youtube :: getId ( $ matches [ 1 ] ) : $ matches [ 1 ] ; return $ this -> Html -> youtube ( $ id ) ; } , $ text ) ; }
Parses Youtube code . You can use video ID or video url .
10,285
public function requestCode ( $ clientRef , $ phoneNumber , $ optionalArgs = array ( ) ) { $ requestCode = new RequestCode ; $ requestCode -> setClientRef ( $ clientRef ) -> setPhoneNumber ( $ phoneNumber ) ; if ( count ( $ optionalArgs ) > 0 ) { foreach ( $ optionalArgs as $ key => $ value ) { $ requestCode -> set ( $...
Request the authentication code
10,286
public function validateCode ( $ clientRef , $ code ) { $ response = $ this -> request ( 'TFA/Validate' , array ( $ clientRef , $ code ) ) ; $ serializer = SerializerBuilder :: create ( ) -> build ( ) ; $ result = $ serializer -> deserialize ( $ response , 'Fortytwo\SDK\TwoFactorAuthentication\Response2FA' , 'json' ) ;...
Validate authentication with the code
10,287
public function sendRequest ( string $ endpoint , array $ queryString = [ ] ) { $ headers = [ 'Accept' => 'application/json' , ] ; if ( $ this -> getApiKey ( ) !== null ) { $ headers [ 'Authorization' ] = base64_encode ( $ this -> getApiKey ( ) ) ; } $ curl = curl_init ( ) ; $ host = $ this -> isSafe === true ? self ::...
Sends request to endpoint and returns decoded response .
10,288
public function process ( ContainerBuilder $ container ) { if ( ! $ container -> hasDefinition ( $ this -> processorFactoryService ) && ! $ container -> hasAlias ( $ this -> processorFactoryService ) ) { return ; } $ dispatcher = $ container -> findDefinition ( $ this -> processorFactoryService ) ; foreach ( $ containe...
Process command processor tagged services and add to command processor factory .
10,289
public function getBlockManagers ( $ slotName ) { $ slotManager = $ this -> templateManager -> getSlotManager ( $ slotName ) ; if ( null === $ slotManager ) { return array ( ) ; } return $ slotManager -> getBlockManagersCollection ( ) -> getBlockManagers ( ) ; }
Returns the block managers handled by the PageTree object
10,290
public function setUp ( ThemeInterface $ theme , TemplateManager $ templateManager , PageBlocksInterface $ pageBlocks , Template $ template = null ) { $ this -> templateManager = $ templateManager ; $ this -> pageBlocks = $ pageBlocks ; $ this -> theme = $ theme ; $ this -> dispatch ( PageTreeEvent \ PageTreeEvents :: ...
Sets up the PageTree object
10,291
protected function setUpMetaTags ( ) { $ seo = $ this -> getSeo ( ) ; if ( null !== $ seo ) { $ this -> metaTitle = $ seo -> getMetaTitle ( ) ; $ this -> metaDescription = $ seo -> getMetaDescription ( ) ; $ this -> metaKeywords = $ seo -> getMetaKeywords ( ) ; } }
Sets up the metatags section
10,292
public function hasBeenProcessed ( array $ identifier ) { list ( $ email , $ website ) = $ identifier ; return isset ( $ this -> customerIdentifierEntityIdMapping [ $ email ] [ $ website ] ) ; }
Queries whether or not the customer with the passed identifier has already been processed .
10,293
protected function manageCollection ( array $ values , $ savedValues = null , $ blockKey = null ) { if ( array_key_exists ( 'Content' , $ values ) ) { $ data = json_decode ( $ values [ 'Content' ] , true ) ; if ( null === $ savedValues ) { $ savedValues = $ this -> decodeJsonContent ( $ this -> alBlock ) ; } if ( $ dat...
Manages the json collection adding and removing items collection from the json block
10,294
public function add ( $ keys ) { foreach ( $ this -> expandKeys ( ( array ) $ keys ) as $ key ) { if ( ! $ this -> has ( $ key ) ) { $ this -> keys [ ] = $ key ; } } return $ this ; }
Add one or more keys . Duplicate keys will be silently ignored .
10,295
public function remove ( $ keys ) { $ keys = ( array ) $ keys ; $ this -> keys = array_filter ( $ this -> keys ( ) , function ( $ key ) use ( $ keys ) { foreach ( $ keys as $ remove ) { if ( preg_match ( '/^' . preg_quote ( $ remove , '/' ) . '(\..+)?$/' , $ key ) ) { return false ; } } return true ; } ) ; }
Remove one or more keys .
10,296
public function setParams ( array $ params ) { if ( ! empty ( $ params ) ) { if ( \ count ( array_filter ( array_keys ( $ params ) , '\is_string' ) ) < 1 ) { throw new ParseIncludesException ( 'Parameters must be an associative array indexed by key' ) ; } } $ this -> params = $ params ; return $ this ; }
An array of parameters indexed by key .
10,297
public function paramsFor ( string $ key ) : array { $ params = [ ] ; if ( isset ( $ this -> params [ $ key ] ) ) { $ params = $ this -> params [ $ key ] ; } return $ params ; }
Get the parameters for the given key An empty array will be returned for non - matched keys .
10,298
public function splice ( $ parentKey ) { $ keys = $ this -> descendantsOf ( $ parentKey ) ; $ params = $ this -> allParamsFor ( $ keys ) ; return new static ( $ keys , $ params ) ; }
Returns a new Includes object containing all keys spliced below the given parent key as well as any mapped params .
10,299
public function allParamsFor ( array $ keys ) : array { $ params = [ ] ; foreach ( $ keys as $ key ) { if ( isset ( $ this -> params [ $ key ] ) ) { $ params [ $ key ] = $ this -> params [ $ key ] ; } } return $ params ; }
Get the parameters for the given keys as an associative array indexed by key An empty array will be returned if there are no matched keys .