idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
47,000
private function match ( $ token ) { if ( ! $ this -> lexer -> isNextToken ( $ token ) ) { $ this -> syntaxError ( $ this -> lexer -> getLiteral ( $ token ) ) ; } return $ this -> lexer -> moveNext ( ) ; }
Attempts to match the given token with the current lookahead token . If they match updates the lookahead token ; otherwise raises a syntax error .
47,001
private function classExists ( $ fqcn ) { if ( isset ( $ this -> classExists [ $ fqcn ] ) ) { return $ this -> classExists [ $ fqcn ] ; } return $ this -> classExists [ $ fqcn ] = class_exists ( $ fqcn ) ; }
Attempts to check if a class exists or not . This always uses PHP autoloading mechanism .
47,002
private function collectAttributeTypeMetadata ( PropertyMetadataBuilder $ metadata , Attribute $ attribute ) : void { $ type = $ attribute -> type ; if ( 'mixed' === $ type ) { return ; } if ( $ attribute -> required ) { $ metadata -> withBeingRequired ( ) ; } if ( false !== $ pos = strpos ( $ type , '<' ) ) { $ arrayT...
Collects parsing metadata for a given attribute .
47,003
public function nextTokenIsAdjacent ( ) : bool { return $ this -> token === null || ( $ this -> lookahead !== null && ( $ this -> lookahead [ 'position' ] - $ this -> token [ 'position' ] ) === strlen ( $ this -> token [ 'value' ] ) ) ; }
Whether the next token starts immediately or if there were non - captured symbols before that
47,004
protected function prepareProcessors ( ) { usort ( $ this -> processors , function ( ProcessorInterface $ one , ProcessorInterface $ two ) { if ( $ one -> getPriority ( ) == $ two -> getPriority ( ) ) { return 0 ; } return $ one -> getPriority ( ) < $ two -> getPriority ( ) ? 1 : - 1 ; } ) ; }
Sort processors by priority
47,005
private function prepare ( $ request ) { $ request -> prepare ( ) ; $ curlOptions = $ this -> composeCurlOptions ( $ request -> getOptions ( ) ) ; $ method = strtoupper ( $ request -> getMethod ( ) ) ; switch ( $ method ) { case 'POST' : $ curlOptions [ CURLOPT_POST ] = true ; break ; default : $ curlOptions [ CURLOPT_...
Prepare request for execution creating cURL resource for it .
47,006
private function initCurl ( array $ curlOptions ) { $ curlResource = curl_init ( ) ; foreach ( $ curlOptions as $ option => $ value ) { curl_setopt ( $ curlResource , $ option , $ value ) ; } return $ curlResource ; }
Initializes cURL resource .
47,007
private function composeCurlOptions ( array $ options ) { static $ optionMap = [ 'protocolVersion' => CURLOPT_HTTP_VERSION , 'maxRedirects' => CURLOPT_MAXREDIRS , 'sslCapath' => CURLOPT_CAPATH , 'sslCafile' => CURLOPT_CAINFO , 'sslLocalCert' => CURLOPT_SSLCERT , 'sslLocalPk' => CURLOPT_SSLKEY , 'sslPassphrase' => CURLO...
Composes cURL options from raw request options .
47,008
private function setHeaderOutput ( $ curlResource , array & $ output ) { curl_setopt ( $ curlResource , CURLOPT_HEADERFUNCTION , function ( $ resource , $ headerString ) use ( & $ output ) { $ header = trim ( $ headerString , "\n\r" ) ; if ( strlen ( $ header ) > 0 ) { $ output [ ] = $ header ; } return mb_strlen ( $ h...
Setup a variable which should collect the cURL response headers .
47,009
protected function getRequestMethod ( $ timing ) { $ timing = ltrim ( $ timing ) ; preg_match ( '/^([a-zA-z]*)/' , $ timing , $ matches ) ; return count ( $ matches ) ? $ matches [ 0 ] : '' ; }
Returns HTTP request method .
47,010
public function getMethods ( ) { return array_reduce ( $ this -> _models , function ( $ result , $ item ) { $ result [ $ item [ 'method' ] ] = $ item [ 'method' ] ; return $ result ; } , [ ] ) ; }
Returns array request methods
47,011
protected function convertXmlToArray ( $ xml ) { if ( is_string ( $ xml ) ) { $ xml = simplexml_load_string ( $ xml , 'SimpleXMLElement' , LIBXML_NOCDATA ) ; } $ result = ( array ) $ xml ; foreach ( $ result as $ key => $ value ) { if ( ! is_scalar ( $ value ) ) { $ result [ $ key ] = $ this -> convertXmlToArray ( $ va...
Converts XML document to array .
47,012
public function getStatusCode ( ) { $ headers = $ this -> getHeaders ( ) ; if ( $ headers -> has ( 'http-code' ) ) { $ statusCodeHeaders = $ headers -> get ( 'http-code' , null , false ) ; return empty ( $ statusCodeHeaders ) ? null : end ( $ statusCodeHeaders ) ; } throw new Exception ( 'Unable to get status code: ref...
Returns status code .
47,013
protected function detectFormatByContent ( $ content ) { if ( preg_match ( '/^(\\{|\\[\\{).*(\\}|\\}\\])$/is' , $ content ) ) { return Client :: FORMAT_JSON ; } if ( preg_match ( '/^([^=&])+=[^=&]+(&[^=&]+=[^=&]+)*$/' , $ content ) ) { return Client :: FORMAT_URLENCODED ; } if ( preg_match ( '/^<\?xml.*>$/s' , $ conten...
Detects response format from raw content .
47,014
public function addContent ( $ name , $ content , $ options = [ ] ) { $ multiPartContent = $ this -> getContent ( ) ; if ( ! is_array ( $ multiPartContent ) ) { $ multiPartContent = [ ] ; } $ options [ 'content' ] = $ content ; $ alias = $ this -> generateContentAlias ( $ name ) ; $ this -> addAliasToContentMap ( $ nam...
Adds a content part for multi - part content request .
47,015
public function addFile ( $ name , $ fileName , $ options = [ ] ) { $ content = file_get_contents ( $ fileName ) ; if ( ! isset ( $ options [ 'mimeType' ] ) ) { $ options [ 'mimeType' ] = FileHelper :: getMimeType ( $ fileName ) ; } if ( ! isset ( $ options [ 'fileName' ] ) ) { $ options [ 'fileName' ] = basename ( $ f...
Adds a file for upload as multi - part content .
47,016
public function addFileContent ( $ name , $ content , $ options = [ ] ) { if ( ! isset ( $ options [ 'mimeType' ] ) ) { $ options [ 'mimeType' ] = 'application/octet-stream' ; } if ( ! isset ( $ options [ 'fileName' ] ) ) { $ options [ 'fileName' ] = $ name . '.dat' ; } return $ this -> addContent ( $ name , $ content ...
Adds a string as a file upload .
47,017
public function prepare ( ) { $ content = $ this -> getContent ( ) ; if ( $ content === null ) { $ this -> getFormatter ( ) -> format ( $ this ) ; } elseif ( is_array ( $ content ) ) { $ this -> prepareMultiPartContent ( $ content ) ; } $ this -> isPrepared = true ; return $ this ; }
Prepares this request instance for sending . This method should be invoked by transport before sending a request . Do not call this method unless you know what you are doing .
47,018
private function createFullUrl ( $ url ) { if ( is_array ( $ url ) ) { $ params = $ url ; if ( isset ( $ params [ 0 ] ) ) { $ url = ( string ) $ params [ 0 ] ; unset ( $ params [ 0 ] ) ; } else { $ url = '' ; } } if ( ! empty ( $ this -> client -> baseUrl ) ) { if ( empty ( $ url ) ) { $ url = $ this -> client -> baseU...
Normalizes given URL value filling it with actual string URL value .
47,019
private function prepareMultiPartContent ( array $ content ) { static $ disallowedChars = [ "\0" , '"' , "\r" , "\n" ] ; $ contentParts = [ ] ; $ data = $ this -> getData ( ) ; if ( ! empty ( $ data ) ) { foreach ( $ this -> composeFormInputs ( $ data ) as $ name => $ value ) { $ name = str_replace ( $ disallowedChars ...
Prepares multi - part content .
47,020
private function generateContentAlias ( $ name ) { $ alias = $ name ; while ( $ this -> hasContent ( $ alias ) ) { $ alias = uniqid ( $ name . '_' ) ; } return $ alias ; }
Generates unique alias for the content
47,021
private function getNameByAlias ( $ alias ) { return isset ( $ this -> _contentMap [ $ alias ] ) ? $ this -> _contentMap [ $ alias ] : $ alias ; }
Returns name by alias from the content map
47,022
public function getFormatter ( $ format ) { static $ defaultFormatters = [ self :: FORMAT_JSON => 'yii\httpclient\JsonFormatter' , self :: FORMAT_URLENCODED => [ 'class' => 'yii\httpclient\UrlEncodedFormatter' , 'encodingType' => PHP_QUERY_RFC1738 ] , self :: FORMAT_RAW_URLENCODED => [ 'class' => 'yii\httpclient\UrlEnc...
Returns HTTP message formatter instance for the specified format .
47,023
public function getParser ( $ format ) { static $ defaultParsers = [ self :: FORMAT_JSON => 'yii\httpclient\JsonParser' , self :: FORMAT_URLENCODED => 'yii\httpclient\UrlEncodedParser' , self :: FORMAT_RAW_URLENCODED => 'yii\httpclient\UrlEncodedParser' , self :: FORMAT_XML => 'yii\httpclient\XmlParser' , ] ; if ( ! is...
Returns HTTP message parser instance for the specified format .
47,024
public function createResponse ( $ content = null , array $ headers = [ ] ) { $ config = $ this -> responseConfig ; if ( ! isset ( $ config [ 'class' ] ) ) { $ config [ 'class' ] = Response :: className ( ) ; } $ config [ 'client' ] = $ this ; $ response = Yii :: createObject ( $ config ) ; $ response -> setContent ( $...
Creates a response instance .
47,025
public function get ( $ url , $ data = null , $ headers = [ ] , $ options = [ ] ) { return $ this -> createRequestShortcut ( 'GET' , $ url , $ data , $ headers , $ options ) ; }
Creates GET request .
47,026
public function post ( $ url , $ data = null , $ headers = [ ] , $ options = [ ] ) { return $ this -> createRequestShortcut ( 'POST' , $ url , $ data , $ headers , $ options ) ; }
Creates POST request .
47,027
public function put ( $ url , $ data = null , $ headers = [ ] , $ options = [ ] ) { return $ this -> createRequestShortcut ( 'PUT' , $ url , $ data , $ headers , $ options ) ; }
Creates PUT request .
47,028
public function patch ( $ url , $ data = null , $ headers = [ ] , $ options = [ ] ) { return $ this -> createRequestShortcut ( 'PATCH' , $ url , $ data , $ headers , $ options ) ; }
Creates PATCH request .
47,029
public function delete ( $ url , $ data = null , $ headers = [ ] , $ options = [ ] ) { return $ this -> createRequestShortcut ( 'DELETE' , $ url , $ data , $ headers , $ options ) ; }
Creates DELETE request .
47,030
public function head ( $ url , $ headers = [ ] , $ options = [ ] ) { return $ this -> createRequestShortcut ( 'HEAD' , $ url , null , $ headers , $ options ) ; }
Creates HEAD request .
47,031
public function getHeaders ( ) { if ( ! is_object ( $ this -> _headers ) ) { $ headerCollection = new HeaderCollection ( ) ; if ( is_array ( $ this -> _headers ) ) { foreach ( $ this -> _headers as $ name => $ value ) { if ( is_int ( $ name ) ) { $ rawHeader = $ value ; if ( strpos ( $ rawHeader , 'HTTP/' ) === 0 ) { $...
Returns the header collection . The header collection contains the HTTP headers associated with HTTP message .
47,032
public function addHeaders ( array $ headers ) { $ headerCollection = $ this -> getHeaders ( ) ; foreach ( $ headers as $ name => $ value ) { $ headerCollection -> add ( $ name , $ value ) ; } return $ this ; }
Adds more headers to the already defined ones .
47,033
public function getCookies ( ) { if ( ! is_object ( $ this -> _cookies ) ) { $ cookieCollection = new CookieCollection ( ) ; if ( is_array ( $ this -> _cookies ) ) { foreach ( $ this -> _cookies as $ cookie ) { if ( ! is_object ( $ cookie ) ) { $ cookie = new Cookie ( $ cookie ) ; } $ cookieCollection -> add ( $ cookie...
Returns the cookie collection . The cookie collection contains the cookies associated with HTTP message .
47,034
public function addCookies ( array $ cookies ) { $ cookieCollection = $ this -> getCookies ( ) ; foreach ( $ cookies as $ cookie ) { if ( ! is_object ( $ cookie ) ) { $ cookie = new Cookie ( $ cookie ) ; } $ cookieCollection -> add ( $ cookie ) ; } return $ this ; }
Adds more cookies to the already defined ones .
47,035
public function hasContent ( $ key ) { $ content = $ this -> getContent ( ) ; return is_array ( $ content ) && isset ( $ content [ $ key ] ) ; }
Checks if content with provided name exists
47,036
public function addData ( $ data ) { if ( empty ( $ this -> _data ) ) { $ this -> _data = $ data ; } else { if ( ! is_array ( $ this -> _data ) ) { throw new \ yii \ base \ Exception ( 'Unable to merge existing data with new data. Existing data is not an array.' ) ; } $ this -> _data = array_merge ( $ this -> _data , $...
Adds data fields to the existing ones .
47,037
public function getFormat ( ) { if ( $ this -> _format === null ) { $ this -> _format = $ this -> defaultFormat ( ) ; } return $ this -> _format ; }
Returns body format .
47,038
public function toString ( ) { $ result = '' ; if ( $ this -> hasHeaders ( ) ) { $ headers = $ this -> composeHeaderLines ( ) ; $ result .= implode ( "\n" , $ headers ) ; } $ content = $ this -> getContent ( ) ; if ( $ content !== null ) { $ result .= "\n\n" . $ content ; } return $ result ; }
Returns string representation of this HTTP message .
47,039
protected function createRequestFromLog ( $ requestLog ) { if ( strpos ( $ requestLog , "\n\n" ) ) { list ( $ head , $ content ) = explode ( "\n\n" , $ requestLog , 2 ) ; } else { $ head = $ requestLog ; $ content = null ; } $ headers = explode ( "\n" , $ head ) ; $ main = array_shift ( $ headers ) ; list ( $ method , ...
Creates an HTTP request instance from log entry .
47,040
private function buildAndCacheFromFactory ( string $ className ) { $ factory = self :: $ cachedInstantiators [ $ className ] = $ this -> buildFactory ( $ className ) ; $ instance = $ factory ( ) ; if ( $ this -> isSafeToClone ( new ReflectionClass ( $ instance ) ) ) { self :: $ cachedCloneables [ $ className ] = clone ...
Builds the requested object and caches it in static properties for performance
47,041
private function hasInternalAncestors ( ReflectionClass $ reflectionClass ) : bool { do { if ( $ reflectionClass -> isInternal ( ) ) { return true ; } $ reflectionClass = $ reflectionClass -> getParentClass ( ) ; } while ( $ reflectionClass ) ; return false ; }
Verifies whether the given class is to be considered internal
47,042
private function getOrganizeMigrationsModes ( ) : array { $ constPrefix = 'VERSIONS_ORGANIZATION_' ; $ prefixLen = strlen ( $ constPrefix ) ; $ refClass = new ReflectionClass ( 'Doctrine\Migrations\Configuration\Configuration' ) ; $ constsArray = $ refClass -> getConstants ( ) ; $ namesArray = [ ] ; foreach ( $ constsA...
Find organize migrations modes for their names
47,043
public function withVideo ( $ videoPath , $ data = [ ] , $ endpoint = 'me/videos' ) { $ this -> video = new video ( $ videoPath , $ endpoint ) ; if ( isset ( $ data [ 'title' ] ) ) { $ this -> video -> setTitle ( $ data [ 'title' ] ) ; } if ( isset ( $ data [ 'description' ] ) ) { $ this -> video -> setDescription ( $ ...
Set facebook post image .
47,044
public function getPostBody ( ) { $ body = [ 'message' => $ this -> getContent ( ) , ] ; if ( $ this -> link != null ) { $ body [ 'link' ] = $ this -> link -> getUrl ( ) ; } if ( $ this -> image != null ) { $ body [ 'media' ] = $ this -> image ; } if ( $ this -> video != null ) { $ body [ 'media' ] = $ this -> video ; ...
Build Facebook post request body .
47,045
private function unserializeAcl ( $ serialized ) { $ acl = unserialize ( $ serialized ) ; $ parentId = $ acl -> getParentAcl ( ) ; if ( null !== $ parentId ) { $ parentAcl = $ this -> getFromCacheById ( $ parentId ) ; if ( null === $ parentAcl ) { return null ; } $ acl -> setParentAcl ( $ parentAcl ) ; } $ reflectionPr...
Unserialize a given ACL .
47,046
private function evictFromCacheByKey ( $ key ) { if ( ! $ this -> cache -> contains ( $ key ) ) { return ; } $ this -> cache -> delete ( $ key ) ; }
Removes an ACL from the cache
47,047
private function getFromCacheByKey ( $ key ) { if ( ! $ this -> cache -> contains ( $ key ) ) { return null ; } $ serialized = $ this -> cache -> fetch ( $ key ) ; return $ this -> unserializeAcl ( $ serialized ) ; }
Retrieves an ACL for the given key from the cache
47,048
protected function getCacheProvider ( $ cacheName ) { $ container = $ this -> getContainer ( ) ; $ cacheProvider = $ container -> get ( $ cacheName , ContainerInterface :: NULL_ON_INVALID_REFERENCE ) ; if ( ! $ cacheProvider instanceof Cache ) { $ cacheProvider = $ container -> get ( 'doctrine_cache.providers.' . $ cac...
Get the requested cache provider service .
47,049
private function addCustomProviderNode ( ) { $ builder = new TreeBuilder ( 'custom_provider' ) ; $ node = $ this -> getRootNode ( $ builder , 'custom_provider' ) ; $ node -> children ( ) -> scalarNode ( 'type' ) -> isRequired ( ) -> cannotBeEmpty ( ) -> end ( ) -> arrayNode ( 'options' ) -> useAttributeAsKey ( 'name' )...
Build custom node configuration definition
47,050
private function addChainNode ( ) { $ builder = new TreeBuilder ( 'chain' ) ; $ node = $ this -> getRootNode ( $ builder , 'chain' ) ; $ node -> fixXmlConfig ( 'provider' ) -> children ( ) -> arrayNode ( 'providers' ) -> prototype ( 'scalar' ) -> end ( ) -> end ( ) -> end ( ) ; return $ node ; }
Build chain node configuration definition
47,051
private function addMemcacheNode ( ) { $ builder = new TreeBuilder ( 'memcache' ) ; $ node = $ this -> getRootNode ( $ builder , 'memcache' ) ; $ host = '%doctrine_cache.memcache.host%' ; $ port = '%doctrine_cache.memcache.port%' ; $ node -> addDefaultsIfNotSet ( ) -> fixXmlConfig ( 'server' ) -> children ( ) -> scalar...
Build memcache node configuration definition
47,052
private function addRedisNode ( ) { $ builder = new TreeBuilder ( 'redis' ) ; $ node = $ this -> getRootNode ( $ builder , 'redis' ) ; $ node -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'connection_id' ) -> defaultNull ( ) -> end ( ) -> scalarNode ( 'host' ) -> defaultValue ( '%doctrine_cache.redis.host%...
Build redis node configuration definition
47,053
private function addPredisNode ( ) { $ builder = new TreeBuilder ( 'predis' ) ; $ node = $ this -> getRootNode ( $ builder , 'predis' ) ; $ node -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'client_id' ) -> defaultNull ( ) -> end ( ) -> scalarNode ( 'scheme' ) -> defaultValue ( 'tcp' ) -> end ( ) -> scala...
Build predis node configuration definition
47,054
private function addRiakNode ( ) { $ builder = new TreeBuilder ( 'riak' ) ; $ node = $ this -> getRootNode ( $ builder , 'riak' ) ; $ node -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'host' ) -> defaultValue ( '%doctrine_cache.riak.host%' ) -> end ( ) -> scalarNode ( 'port' ) -> defaultValue ( '%doctrine...
Build riak node configuration definition
47,055
private function addCouchbaseNode ( ) { $ builder = new TreeBuilder ( 'couchbase' ) ; $ node = $ this -> getRootNode ( $ builder , 'couchbase' ) ; $ node -> addDefaultsIfNotSet ( ) -> fixXmlConfig ( 'hostname' ) -> children ( ) -> scalarNode ( 'connection_id' ) -> defaultNull ( ) -> end ( ) -> arrayNode ( 'hostnames' )...
Build couchbase node configuration definition
47,056
private function addMongoNode ( ) { $ builder = new TreeBuilder ( 'mongodb' ) ; $ node = $ this -> getRootNode ( $ builder , 'mongodb' ) ; $ node -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'connection_id' ) -> defaultNull ( ) -> end ( ) -> scalarNode ( 'collection_id' ) -> defaultNull ( ) -> end ( ) -> ...
Build mongodb node configuration definition
47,057
private function addPhpFileNode ( ) { $ builder = new TreeBuilder ( 'php_file' ) ; $ node = $ this -> getRootNode ( $ builder , 'php_file' ) ; $ node -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'directory' ) -> defaultValue ( '%kernel.cache_dir%/doctrine/cache/phpfile' ) -> end ( ) -> scalarNode ( 'exten...
Build php_file node configuration definition
47,058
private function addSqlite3Node ( ) { $ builder = new TreeBuilder ( 'sqlite3' ) ; $ node = $ this -> getRootNode ( $ builder , 'sqlite3' ) ; $ node -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'connection_id' ) -> defaultNull ( ) -> end ( ) -> scalarNode ( 'file_name' ) -> defaultNull ( ) -> end ( ) -> sc...
Build sqlite3 node configuration definition
47,059
public function cascade ( $ models , $ direction , array $ directionData = [ ] ) { try { $ this -> direction = $ direction ; $ this -> directionData = $ directionData ; $ this -> run ( $ models ) ; foreach ( $ this -> dbsToTransact as $ connectionToTransact ) { DB :: connection ( $ connectionToTransact ) -> commit ( ) ...
Cascade over Eloquent items .
47,060
protected function run ( $ models ) { $ models = collect ( $ models ) ; if ( $ models -> count ( ) > 0 ) { $ model = $ models -> first ( ) ; if ( ! is_object ( $ model ) ) { return ; } if ( ! $ this -> isCascadable ( $ model ) ) { return ; } if ( ! in_array ( $ model -> getConnectionName ( ) , $ this -> dbsToTransact )...
Run the cascade .
47,061
protected function relations ( $ model , $ foreignKeyIds ) { $ relations = $ model -> getSoftCascade ( ) ; if ( empty ( $ relations ) ) { return ; } foreach ( $ relations as $ relation ) { extract ( $ this -> relationResolver ( $ relation ) ) ; $ this -> validateRelation ( $ model , $ relation ) ; $ modelRelation = $ m...
Iterate over the relations .
47,062
protected function getBelongsToManyData ( $ relation , $ relationForeignKey , $ foreignKeyIds ) { $ relationConnection = $ relation -> getConnection ( ) -> getName ( ) ; $ relationTable = $ relation -> getTable ( ) ; $ relationRelatedKey = $ relation -> getQualifiedRelatedPivotKeyName ( ) ; $ foreignKeyIdsUse = DB :: c...
Get many to many related key ids and key use .
47,063
protected function getMorphManyData ( $ relation , $ foreignKeyIds ) { $ relatedClass = $ relation -> getRelated ( ) ; $ foreignKeyUse = $ relatedClass -> getKeyName ( ) ; $ foreignKeyIdsUse = $ relatedClass :: withTrashed ( ) -> where ( $ relation -> getMorphType ( ) , $ relation -> getMorphClass ( ) ) -> whereIn ( $ ...
Get morph many related key ids and key use .
47,064
protected function execute ( $ relation , $ foreignKey , $ foreignKeyIds , $ affectedRows ) { $ relationModel = $ relation -> getQuery ( ) -> getModel ( ) ; $ relationModel = new $ relationModel ( ) ; if ( $ affectedRows > 0 ) { $ relationModel = $ relationModel -> withTrashed ( ) -> whereIn ( $ foreignKey , $ foreignK...
Execute delete or restore .
47,065
protected function validateRelation ( $ model , $ relation ) { $ class = get_class ( $ model ) ; if ( ! method_exists ( $ model , $ relation ) ) { DB :: rollBack ( ) ; throw new \ LogicException ( sprintf ( '%s does not have method \'%s\'.' , $ class , $ relation ) ) ; } if ( ! $ model -> $ relation ( ) instanceof \ Il...
Validate the relation method exists and is a type of Eloquent Relation .
47,066
protected function affectedRows ( $ relation , $ foreignKey , $ foreignKeyIds ) { $ relationModel = $ relation -> getQuery ( ) -> getModel ( ) ; $ relationModel = new $ relationModel ( ) ; return $ relationModel -> withTrashed ( ) -> whereIn ( $ foreignKey , $ foreignKeyIds ) -> count ( ) ; }
Affected rows if we do execute .
47,067
protected function relationResolver ( $ relation ) { $ return = [ 'relation' => '' , 'action' => 'update' ] ; try { list ( $ relation , $ action ) = explode ( '@' , $ relation ) ; $ return = [ 'relation' => $ relation , 'action' => $ action ] ; } catch ( \ Exception $ e ) { $ return [ 'relation' ] = $ relation ; } if (...
Resolve relation string .
47,068
private function getBacktraceUse ( ) { $ debugBacktrace = collect ( debug_backtrace ( DEBUG_BACKTRACE_PROVIDE_OBJECT , 30 ) ) -> filter ( function ( $ backtrace ) { $ backtraceClass = ( isset ( $ backtrace [ 'class' ] ) ) ? $ backtrace [ 'class' ] : null ; return $ backtraceClass === $ this -> listenClass ; } ) -> firs...
Return the backtrace will be use to get model object and function .
47,069
public function handle ( ) { $ checkBacktrace = $ this -> getBacktraceUse ( ) ; if ( ! is_null ( $ checkBacktrace ) ) { $ model = $ checkBacktrace [ 'object' ] -> withTrashed ( ) -> get ( [ $ checkBacktrace [ 'object' ] -> getModel ( ) -> getKeyName ( ) ] ) ; ( new QueryBuilderSoftCascade ( ) ) -> cascade ( $ model , $...
Handel the event for eloquent delete .
47,070
public function setModel ( $ model , $ foreignKey , $ foreignKeyIds ) { $ this -> model = $ model ; $ this -> foreignKey = $ foreignKey ; $ this -> foreignKeyIds = array_wrap ( $ foreignKeyIds ) ; $ this -> message = "Integrity constraint violation [{$model}] where $foreignKey in (" . implode ( ', ' , $ foreignKeyIds )...
Set the affected Eloquent model and instance foreignKeyIds .
47,071
private function changeReference ( Reference $ reference , $ serviceId ) { if ( method_exists ( $ reference , 'isStrict' ) ) { return new Reference ( $ serviceId , $ reference -> getInvalidBehavior ( ) , $ reference -> isStrict ( false ) ) ; } return new Reference ( $ serviceId , $ reference -> getInvalidBehavior ( ) )...
Creates a copy of a reference and alters the service ID .
47,072
public function createMessage ( $ content , array $ records ) { $ message = $ this -> mailer -> createMessage ( ) ; $ message -> setTo ( $ this -> toEmail ) ; $ message -> setFrom ( $ this -> fromEmail ) ; $ message -> setSubject ( $ this -> subject ) ; if ( $ this -> contentType ) { $ message -> setContentType ( $ thi...
Creates a Swift_Message template that will be used to send the log message
47,073
public function isSatisfied ( $ dateValue , $ value ) { if ( $ this -> isIncrementsOfRanges ( $ value ) ) { return $ this -> isInIncrementsOfRanges ( $ dateValue , $ value ) ; } elseif ( $ this -> isRange ( $ value ) ) { return $ this -> isInRange ( $ dateValue , $ value ) ; } return $ value == '*' || $ dateValue == $ ...
Check to see if a field is satisfied by a value
47,074
public function isInRange ( $ dateValue , $ value ) { $ parts = array_map ( 'trim' , explode ( '-' , $ value , 2 ) ) ; return $ dateValue >= $ parts [ 0 ] && $ dateValue <= $ parts [ 1 ] ; }
Test if a value is within a range
47,075
public function getRangeForExpression ( $ expression , $ max ) { $ values = array ( ) ; if ( $ this -> isRange ( $ expression ) || $ this -> isIncrementsOfRanges ( $ expression ) ) { if ( ! $ this -> isIncrementsOfRanges ( $ expression ) ) { list ( $ offset , $ to ) = explode ( '-' , $ expression ) ; $ stepSize = 1 ; }...
Returns a range of values for the given cron expression
47,076
public function validate ( $ value ) { $ value = $ this -> convertLiterals ( $ value ) ; if ( '*' === $ value ) { return true ; } if ( strpos ( $ value , ',' ) !== false && strpos ( $ value , '-' ) !== false ) { return false ; } if ( strpos ( $ value , '/' ) !== false ) { list ( $ range , $ step ) = explode ( '/' , $ v...
Checks to see if a value is valid for the field
47,077
public function getMultipleRunDates ( $ total , $ currentTime = 'now' , $ invert = false , $ allowCurrentDate = false , $ timeZone = null ) { $ matches = array ( ) ; for ( $ i = 0 ; $ i < max ( 0 , $ total ) ; $ i ++ ) { try { $ matches [ ] = $ this -> getRunDate ( $ currentTime , $ i , $ invert , $ allowCurrentDate , ...
Get multiple run dates starting at the current date or a specific date
47,078
public function getExpression ( $ part = null ) { if ( null === $ part ) { return implode ( ' ' , $ this -> cronParts ) ; } elseif ( array_key_exists ( $ part , $ this -> cronParts ) ) { return $ this -> cronParts [ $ part ] ; } return null ; }
Get all or part of the CRON expression
47,079
public function isDue ( $ currentTime = 'now' , $ timeZone = null ) { if ( is_null ( $ timeZone ) ) { $ timeZone = date_default_timezone_get ( ) ; } if ( 'now' === $ currentTime ) { $ currentDate = date ( 'Y-m-d H:i' ) ; $ currentTime = strtotime ( $ currentDate ) ; } elseif ( $ currentTime instanceof DateTime ) { $ cu...
Determine if the cron is due to run based on the current date or a specific date . This method assumes that the current number of seconds are irrelevant and should be called once per minute .
47,080
private static function getNearestWeekday ( $ currentYear , $ currentMonth , $ targetDay ) { $ tday = str_pad ( $ targetDay , 2 , '0' , STR_PAD_LEFT ) ; $ target = DateTime :: createFromFormat ( 'Y-m-d' , "$currentYear-$currentMonth-$tday" ) ; $ currentWeekday = ( int ) $ target -> format ( 'N' ) ; if ( $ currentWeekda...
Get the nearest day of the week for a given day in a month
47,081
protected function setKeysInEnvironmentFile ( $ keys ) { $ currentKeys = $ this -> laravel [ 'config' ] [ 'webpush.vapid' ] ; if ( strlen ( $ currentKeys [ 'public_key' ] ) !== 0 && ( ! $ this -> confirmToProceed ( ) ) ) { return false ; } $ this -> writeNewEnvironmentFileWith ( $ keys ) ; return true ; }
Set the keys in the environment file .
47,082
protected function writeNewEnvironmentFileWith ( $ keys ) { $ contents = file_get_contents ( $ this -> laravel -> environmentFilePath ( ) ) ; if ( ! Str :: contains ( $ contents , 'VAPID_PUBLIC_KEY' ) ) { $ contents .= PHP_EOL . 'VAPID_PUBLIC_KEY=' ; } if ( ! Str :: contains ( $ contents , 'VAPID_PRIVATE_KEY' ) ) { $ c...
Write a new environment file with the given keys .
47,083
protected function getFrames ( Inspector $ inspector ) : array { return $ inspector -> getFrames ( ) -> filter ( function ( $ frame ) { foreach ( $ this -> ignore as $ ignore ) { if ( preg_match ( $ ignore , $ frame -> getFile ( ) ) ) { return false ; } } return true ; } ) -> getArray ( ) ; }
Returns pertinent frames .
47,084
protected function renderTitle ( Inspector $ inspector ) : WriterContract { $ exception = $ inspector -> getException ( ) ; $ message = $ exception -> getMessage ( ) ; $ class = $ inspector -> getExceptionName ( ) ; $ this -> render ( "<bg=red;options=bold> $class </> : <comment>$message</>" ) ; return $ this ; }
Renders the title of the exception .
47,085
protected function renderEditor ( Frame $ frame ) : WriterContract { $ this -> render ( 'at <fg=green>' . $ frame -> getFile ( ) . '</>' . ':<fg=green>' . $ frame -> getLine ( ) . '</>' ) ; $ content = $ this -> highlighter -> highlight ( ( string ) $ frame -> getFileContents ( ) , ( int ) $ frame -> getLine ( ) ) ; $ ...
Renders the editor containing the code that was the origin of the exception .
47,086
protected function renderTrace ( array $ frames ) : WriterContract { $ this -> render ( '<comment>Exception trace:</comment>' ) ; foreach ( $ frames as $ i => $ frame ) { if ( $ i > static :: VERBOSITY_NORMAL_FRAMES && $ this -> output -> getVerbosity ( ) < OutputInterface :: VERBOSITY_VERBOSE ) { $ this -> render ( '<...
Renders the trace of the exception .
47,087
protected function render ( string $ message , bool $ break = true ) : WriterContract { if ( $ break ) { $ this -> output -> writeln ( '' ) ; } $ this -> output -> writeln ( " $message" ) ; return $ this ; }
Renders an message into the console .
47,088
private function getReplyTo ( Swift_Mime_SimpleMessage $ message ) { if ( $ message -> getReplyTo ( ) ) { foreach ( $ message -> getReplyTo ( ) as $ email => $ name ) { return [ 'email' => $ email , 'name' => $ name ] ; } } return null ; }
Get ReplyTo Addresses .
47,089
protected function setParameters ( Swift_Mime_SimpleMessage $ message , $ data ) { $ this -> numberOfRecipients = 0 ; $ smtp_api = [ ] ; foreach ( $ message -> getChildren ( ) as $ attachment ) { if ( ! $ attachment instanceof Swift_Image || ! in_array ( self :: SMTP_API_NAME , [ $ attachment -> getFilename ( ) , $ att...
Set Request Body Parameters
47,090
public static function getEntityClassFromObjectID ( $ objectID ) { $ type = explode ( '::' , $ objectID ) [ 0 ] ; if ( in_array ( $ type , static :: getEntities ( ) , true ) ) { return $ type ; } throw new EntityNotFoundInObjectID ( "Entity class from ObjectID {$objectID} not found." ) ; }
Returns an entity class name from the provided object id .
47,091
private function forEachChunk ( ObjectManager $ objectManager , array $ entities , $ operation ) { $ batch = [ ] ; foreach ( array_chunk ( $ entities , $ this -> configuration [ 'batchSize' ] ) as $ chunk ) { $ searchableEntitiesChunk = [ ] ; foreach ( $ chunk as $ entity ) { $ entityClassName = ClassUtils :: getClass ...
For each chunk performs the provided operation .
47,092
private function getAggregatorsFromEntities ( ObjectManager $ objectManager , array $ entities ) { $ aggregators = [ ] ; foreach ( $ entities as $ entity ) { $ entityClassName = ClassUtils :: getClass ( $ entity ) ; if ( array_key_exists ( $ entityClassName , $ this -> entitiesAggregators ) ) { foreach ( $ this -> enti...
Returns the aggregators instances of the provided entities .
47,093
protected function getGoogleFontService ( ) { if ( $ this -> googleFontService === null ) { $ this -> googleFontService = GeneralUtility :: makeInstance ( GoogleFontService :: class ) ; } return $ this -> googleFontService ; }
Get the google font service
47,094
protected function pushBlock ( $ selectors , $ pos = 0 ) { list ( $ line , $ column ) = $ this -> getSourcePosition ( $ pos ) ; $ b = new Block ; $ b -> sourceName = $ this -> sourceName ; $ b -> sourceLine = $ line ; $ b -> sourceColumn = $ column ; $ b -> sourceIndex = $ this -> sourceIndex ; $ b -> selectors = $ sel...
Push block onto parse tree
47,095
protected function hasSelectorPlaceholder ( $ selector ) { if ( ! is_array ( $ selector ) ) { return false ; } foreach ( $ selector as $ parts ) { foreach ( $ parts as $ part ) { if ( is_array ( $ part ) ) { return false ; } if ( strlen ( $ part ) && '%' === $ part [ 0 ] ) { return true ; } } } return false ; }
Has selector placeholder?
47,096
private function createConfigurationFile ( $ filename ) { $ absFilename = GeneralUtility :: getFileAbsFileName ( $ filename ) ; if ( file_exists ( $ absFilename ) ) { $ flashMessage = GeneralUtility :: makeInstance ( FlashMessage :: class , 'There is already an ' . $ filename . ' configuration file in the root director...
Creates webserver configuration file inside the root directory
47,097
public function addFlashMessage ( FlashMessage $ flashMessage ) { $ flashMessageService = GeneralUtility :: makeInstance ( FlashMessageService :: class ) ; $ flashMessageQueue = $ flashMessageService -> getMessageQueueByIdentifier ( $ this -> messageQueueByIdentifier ) ; $ flashMessageQueue -> enqueue ( $ flashMessage ...
Adds a Flash Message to the Flash Message Queue
47,098
public function getEmbedCode ( $ url , $ class ) { $ url = $ this -> setProtocolToHttps ( $ url ) ; $ method = $ this -> getMethod ( $ url ) ; if ( $ method !== null ) { $ embedUrl = $ this -> { $ method } ( $ url ) ; if ( $ embedUrl ) { return '<iframe ' . GeneralUtility :: implodeAttributes ( [ 'class' => $ class , '...
Get the embed code for the given url if possible and add a css class on the iframe
47,099
protected function getMethod ( $ url ) { $ urlInformation = @ parse_url ( $ url ) ; $ hostName = GeneralUtility :: trimExplode ( '.' , $ urlInformation [ 'host' ] , true ) ; foreach ( $ this -> mediaProvider as $ provider ) { $ functionName = 'process' . ucfirst ( $ provider ) ; if ( in_array ( $ provider , $ hostName ...
Resolves if possible a method name to process the url