idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
20,400
public function injectModel ( ) { $ params = func_get_args ( ) ; $ injection = array_shift ( $ params ) ; if ( $ injection == false ) { $ url = $ this -> router -> generate ( 'extjs_generate_model' , array ( 'model' => $ params ) , false ) ; return "<script type='text/javascript' src='$url'></script>" ; } else { $ code = '' ; foreach ( $ params as $ model ) { $ model = str_replace ( "." , "\\" , $ model ) ; $ code .= $ this -> generator -> generateMarkupForEntity ( $ model ) ; } return $ code ; } }
Inject ExtJs Model into the DOM .
20,401
public function beforeSave ( Event $ event , EntityInterface $ entity , ArrayObject $ options ) : void { if ( ! $ entity -> get ( 'icon' ) ) { $ entity -> set ( 'icon' , Configure :: read ( 'Icons.default' ) ) ; } if ( ! $ entity -> get ( 'url' ) ) { $ entity -> set ( 'url' , '#' ) ; } }
Fallback to default values for icon and url
20,402
public function set ( $ name , $ value , $ where = '' ) { if ( ( $ name && $ this -> canSetProperty ( $ name ) ) || strpos ( $ name , 'on ' ) === 0 || strpos ( $ name , 'as ' ) === 0 ) { parent :: __set ( $ name , $ value ) ; } else { $ this -> setItem ( $ name , $ value , $ where ) ; } }
Sets an item . Silently resets if already exists .
20,403
public function add ( $ name , $ value = null , $ where = '' ) { if ( ! $ this -> has ( $ name ) ) { $ this -> set ( $ name , $ value , $ where ) ; } return $ this ; }
Adds an item . Does not touch if already exists .
20,404
private function processCopyrightTags ( File $ phpcs_file , $ stack_ptr , $ comment_start ) : void { $ tokens = $ phpcs_file -> getTokens ( ) ; foreach ( $ tokens [ $ comment_start ] [ 'comment_tags' ] as $ tag ) { if ( $ tokens [ $ tag ] [ 'content' ] === $ this -> copyright_tag ) { $ this -> checkForContentInCopyrightTag ( $ phpcs_file , $ tag , $ tokens [ $ comment_start ] [ 'comment_closer' ] ) ; $ this -> processCopyright ( $ phpcs_file , [ $ tag ] ) ; return ; } } $ error = 'Missing ' . $ this -> copyright_tag . ' tag in file doc-block' ; if ( false === $ phpcs_file -> addFixableError ( $ error , $ stack_ptr , 'MissingCopyrightTag' ) ) { return ; } if ( $ tokens [ $ tokens [ $ comment_start ] [ 'comment_closer' ] ] [ 'line' ] === $ tokens [ $ comment_start ] [ 'line' ] ) { $ phpcs_file -> fixer -> replaceToken ( $ tokens [ $ comment_start ] [ 'comment_closer' ] - 1 , '' ) ; $ phpcs_file -> fixer -> addContentBefore ( $ tokens [ $ comment_start ] [ 'comment_closer' ] , sprintf ( "\n * %s %s\n " , $ this -> copyright_tag , $ this -> getCopyrightLine ( ) ) ) ; return ; } $ phpcs_file -> fixer -> addContentBefore ( $ tokens [ $ comment_start ] [ 'comment_closer' ] , sprintf ( "* %s %s\n " , $ this -> copyright_tag , $ this -> getCopyrightLine ( ) ) ) ; }
Processes the file level doc - block tags this function is executed once the parent class finds a file - level doc - block .
20,405
public function getItem ( $ name , $ default = null ) { if ( empty ( $ this -> _items [ $ name ] ) ) { $ this -> _items [ $ name ] = $ default ; } $ item = & $ this -> _items [ $ name ] ; if ( is_array ( $ item ) || is_null ( $ item ) ) { $ item = $ this -> createItem ( $ name , $ item ? : [ ] ) ; } return $ item ; }
Returns item by name . Instantiates it before .
20,406
public function getItems ( ) { foreach ( $ this -> _items as $ name => $ item ) { $ this -> getItem ( $ name ) ; } return $ this -> _items ; }
Get them all as array of items! Instantiates all the items .
20,407
public function withoutQueryValue ( $ key ) : UriExtended { $ current = $ this -> getQuery ( ) ; if ( $ current === '' ) { return $ this ; } $ decodedKey = \ rawurldecode ( $ key ) ; $ result = \ array_filter ( \ explode ( '&' , $ current ) , function ( $ part ) use ( $ decodedKey ) { return \ rawurldecode ( \ explode ( '=' , $ part ) [ 0 ] ) !== $ decodedKey ; } ) ; return $ this -> withQuery ( \ implode ( '&' , $ result ) ) ; }
removes a specific query string value .
20,408
public function initAttributeAttributeTypes ( $ overrideExisting = true ) { if ( null !== $ this -> collAttributeAttributeTypes && ! $ overrideExisting ) { return ; } $ this -> collAttributeAttributeTypes = new ObjectCollection ( ) ; $ this -> collAttributeAttributeTypes -> setModel ( '\AttributeType\Model\AttributeAttributeType' ) ; }
Initializes the collAttributeAttributeTypes collection .
20,409
public function getAttributeAttributeTypes ( $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collAttributeAttributeTypesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collAttributeAttributeTypes || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collAttributeAttributeTypes ) { $ this -> initAttributeAttributeTypes ( ) ; } else { $ collAttributeAttributeTypes = ChildAttributeAttributeTypeQuery :: create ( null , $ criteria ) -> filterByAttributeType ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collAttributeAttributeTypesPartial && count ( $ collAttributeAttributeTypes ) ) { $ this -> initAttributeAttributeTypes ( false ) ; foreach ( $ collAttributeAttributeTypes as $ obj ) { if ( false == $ this -> collAttributeAttributeTypes -> contains ( $ obj ) ) { $ this -> collAttributeAttributeTypes -> append ( $ obj ) ; } } $ this -> collAttributeAttributeTypesPartial = true ; } reset ( $ collAttributeAttributeTypes ) ; return $ collAttributeAttributeTypes ; } if ( $ partial && $ this -> collAttributeAttributeTypes ) { foreach ( $ this -> collAttributeAttributeTypes as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collAttributeAttributeTypes [ ] = $ obj ; } } } $ this -> collAttributeAttributeTypes = $ collAttributeAttributeTypes ; $ this -> collAttributeAttributeTypesPartial = false ; } } return $ this -> collAttributeAttributeTypes ; }
Gets an array of ChildAttributeAttributeType objects which contain a foreign key that references this object .
20,410
public function countAttributeAttributeTypes ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collAttributeAttributeTypesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collAttributeAttributeTypes || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collAttributeAttributeTypes ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getAttributeAttributeTypes ( ) ) ; } $ query = ChildAttributeAttributeTypeQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByAttributeType ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collAttributeAttributeTypes ) ; }
Returns the number of related AttributeAttributeType objects .
20,411
public function addAttributeAttributeType ( ChildAttributeAttributeType $ l ) { if ( $ this -> collAttributeAttributeTypes === null ) { $ this -> initAttributeAttributeTypes ( ) ; $ this -> collAttributeAttributeTypesPartial = true ; } if ( ! in_array ( $ l , $ this -> collAttributeAttributeTypes -> getArrayCopy ( ) , true ) ) { $ this -> doAddAttributeAttributeType ( $ l ) ; } return $ this ; }
Method called to associate a ChildAttributeAttributeType object to this object through the ChildAttributeAttributeType foreign key attribute .
20,412
public function getAttributeAttributeTypesJoinAttribute ( $ criteria = null , $ con = null , $ joinBehavior = Criteria :: LEFT_JOIN ) { $ query = ChildAttributeAttributeTypeQuery :: create ( null , $ criteria ) ; $ query -> joinWith ( 'Attribute' , $ joinBehavior ) ; return $ this -> getAttributeAttributeTypes ( $ query , $ con ) ; }
If this collection has already been initialized with an identical criteria it returns the collection . Otherwise if this AttributeType is new it will return an empty collection ; or if this AttributeType has previously been saved it will retrieve related AttributeAttributeTypes from storage .
20,413
public function initAttributeTypeI18ns ( $ overrideExisting = true ) { if ( null !== $ this -> collAttributeTypeI18ns && ! $ overrideExisting ) { return ; } $ this -> collAttributeTypeI18ns = new ObjectCollection ( ) ; $ this -> collAttributeTypeI18ns -> setModel ( '\AttributeType\Model\AttributeTypeI18n' ) ; }
Initializes the collAttributeTypeI18ns collection .
20,414
public function getAttributeTypeI18ns ( $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collAttributeTypeI18nsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collAttributeTypeI18ns || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collAttributeTypeI18ns ) { $ this -> initAttributeTypeI18ns ( ) ; } else { $ collAttributeTypeI18ns = ChildAttributeTypeI18nQuery :: create ( null , $ criteria ) -> filterByAttributeType ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collAttributeTypeI18nsPartial && count ( $ collAttributeTypeI18ns ) ) { $ this -> initAttributeTypeI18ns ( false ) ; foreach ( $ collAttributeTypeI18ns as $ obj ) { if ( false == $ this -> collAttributeTypeI18ns -> contains ( $ obj ) ) { $ this -> collAttributeTypeI18ns -> append ( $ obj ) ; } } $ this -> collAttributeTypeI18nsPartial = true ; } reset ( $ collAttributeTypeI18ns ) ; return $ collAttributeTypeI18ns ; } if ( $ partial && $ this -> collAttributeTypeI18ns ) { foreach ( $ this -> collAttributeTypeI18ns as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collAttributeTypeI18ns [ ] = $ obj ; } } } $ this -> collAttributeTypeI18ns = $ collAttributeTypeI18ns ; $ this -> collAttributeTypeI18nsPartial = false ; } } return $ this -> collAttributeTypeI18ns ; }
Gets an array of ChildAttributeTypeI18n objects which contain a foreign key that references this object .
20,415
public function countAttributeTypeI18ns ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collAttributeTypeI18nsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collAttributeTypeI18ns || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collAttributeTypeI18ns ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getAttributeTypeI18ns ( ) ) ; } $ query = ChildAttributeTypeI18nQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByAttributeType ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collAttributeTypeI18ns ) ; }
Returns the number of related AttributeTypeI18n objects .
20,416
public function addAttributeTypeI18n ( ChildAttributeTypeI18n $ l ) { if ( $ l && $ locale = $ l -> getLocale ( ) ) { $ this -> setLocale ( $ locale ) ; $ this -> currentTranslations [ $ locale ] = $ l ; } if ( $ this -> collAttributeTypeI18ns === null ) { $ this -> initAttributeTypeI18ns ( ) ; $ this -> collAttributeTypeI18nsPartial = true ; } if ( ! in_array ( $ l , $ this -> collAttributeTypeI18ns -> getArrayCopy ( ) , true ) ) { $ this -> doAddAttributeTypeI18n ( $ l ) ; } return $ this ; }
Method called to associate a ChildAttributeTypeI18n object to this object through the ChildAttributeTypeI18n foreign key attribute .
20,417
public function validate ( Validator $ validator = null ) { if ( null === $ validator ) { $ validator = new Validator ( new ClassMetadataFactory ( new StaticMethodLoader ( ) ) , new ConstraintValidatorFactory ( ) , new DefaultTranslator ( ) ) ; } $ failureMap = new ConstraintViolationList ( ) ; if ( ! $ this -> alreadyInValidation ) { $ this -> alreadyInValidation = true ; $ retval = null ; $ retval = $ validator -> validate ( $ this ) ; if ( count ( $ retval ) > 0 ) { $ failureMap -> addAll ( $ retval ) ; } if ( null !== $ this -> collAttributeAttributeTypes ) { foreach ( $ this -> collAttributeAttributeTypes as $ referrerFK ) { if ( method_exists ( $ referrerFK , 'validate' ) ) { if ( ! $ referrerFK -> validate ( $ validator ) ) { $ failureMap -> addAll ( $ referrerFK -> getValidationFailures ( ) ) ; } } } } if ( null !== $ this -> collAttributeTypeI18ns ) { foreach ( $ this -> collAttributeTypeI18ns as $ referrerFK ) { if ( method_exists ( $ referrerFK , 'validate' ) ) { if ( ! $ referrerFK -> validate ( $ validator ) ) { $ failureMap -> addAll ( $ referrerFK -> getValidationFailures ( ) ) ; } } } } $ this -> alreadyInValidation = false ; } $ this -> validationFailures = $ failureMap ; return ( Boolean ) ( ! ( count ( $ this -> validationFailures ) > 0 ) ) ; }
Validates the object and all objects related to this table .
20,418
public function logQueries ( $ enable = null ) { if ( $ enable !== null ) { $ this -> _logQueries = $ enable ; } if ( $ this -> _logQueries ) { return $ this -> _logQueries ; } return $ this -> _logQueries = $ enable ; }
Enables or disables query logging for this connection .
20,419
public function logger ( $ logger = null ) { if ( $ logger ) { $ this -> _logger = $ logger ; } if ( $ this -> _logger ) { return $ this -> _logger ; } $ this -> _logger = new QueryLogger ( ) ; return $ this -> _logger ; }
Sets the logger object instance . When called with no arguments it returns the currently setup logger instance .
20,420
public function connect ( ) { $ connection = $ this -> _connection ; $ connection -> setLogin ( $ this -> _config [ 'user' ] ) ; $ connection -> setPassword ( $ this -> _config [ 'password' ] ) ; $ connection -> setHost ( $ this -> _config [ 'host' ] ) ; $ connection -> setPort ( $ this -> _config [ 'port' ] ) ; $ connection -> setVhost ( $ this -> _config [ 'vhost' ] ) ; $ connection -> setReadTimeout ( $ this -> _config [ 'readTimeout' ] ) ; $ connection -> connect ( ) ; }
Connects to RabbitMQ
20,421
public function channel ( $ name , $ options = [ ] ) { if ( empty ( $ this -> _channels [ $ name ] ) ) { $ this -> _channels [ $ name ] = new AMQPChannel ( $ this -> connection ( ) ) ; if ( ! empty ( $ options [ 'prefetchCount' ] ) ) { $ this -> _channels [ $ name ] -> setPrefetchCount ( ( int ) $ options [ 'prefetchCount' ] ) ; } } return $ this -> _channels [ $ name ] ; }
Creates a new channel to communicate with an exchange or queue object
20,422
public function exchange ( $ name , $ options = [ ] ) { if ( empty ( $ this -> _exchanges [ $ name ] ) ) { $ channel = $ this -> channel ( $ name , $ options ) ; $ exchange = new AMQPExchange ( $ channel ) ; $ exchange -> setName ( $ name ) ; if ( ! empty ( $ options [ 'type' ] ) ) { $ exchange -> setType ( $ options [ 'type' ] ) ; } if ( ! empty ( $ options [ 'flags' ] ) ) { $ exchange -> setFlags ( $ options [ 'flags' ] ) ; } $ this -> _exchanges [ $ name ] = $ exchange ; } return $ this -> _exchanges [ $ name ] ; }
Connects to an exchange with the given name the object returned can be used to configure and create a new one .
20,423
public function queue ( $ name , $ options = [ ] ) { if ( empty ( $ this -> _queues [ $ name ] ) ) { $ channel = $ this -> channel ( $ name , $ options ) ; $ queue = new AMQPQueue ( $ channel ) ; $ queue -> setName ( $ name ) ; if ( ! empty ( $ options [ 'flags' ] ) ) { $ queue -> setFlags ( $ options [ 'flags' ] ) ; } $ this -> _queues [ $ name ] = $ queue ; } return $ this -> _queues [ $ name ] ; }
Connects to a queue with the given name the object returned can be used to configure and create a new one .
20,424
protected function _prepareMessage ( $ data , array $ options ) { $ attributes = [ ] ; $ options += [ 'silent' => false , 'compress' => true , 'serializer' => extension_loaded ( 'msgpack' ) ? 'msgpack' : 'json' , 'delivery_mode' => 1 ] ; switch ( $ options [ 'serializer' ] ) { case 'json' : $ data = json_encode ( $ data ) ; $ attributes [ 'content_type' ] = 'application/json' ; break ; case 'text' : $ attributes [ 'content_type' ] = 'application/text' ; break ; default : throw new RuntimeException ( 'Unknown serializer: ' . $ options [ 'serializer' ] ) ; } if ( ! empty ( $ options [ 'compress' ] ) ) { $ data = gzcompress ( $ data ) ; $ attributes += [ 'content_encoding' => 'gzip' ] ; } if ( ! empty ( $ options [ 'delivery_mode' ] ) ) { $ attributes [ 'delivery_mode' ] = $ options [ 'delivery_mode' ] ; } return [ $ data , $ attributes , $ options ] ; }
Prepare a message by serializing optionally compressing and setting the correct content type and content type for the message going to RabbitMQ
20,425
protected function chkKidMapTrue ( $ nID ) { $ found = false ; if ( sizeof ( $ this -> kidMaps ) > 0 ) { foreach ( $ this -> kidMaps as $ parent => $ kids ) { if ( sizeof ( $ kids ) > 0 ) { foreach ( $ kids as $ nKid => $ ress ) { if ( $ nID == $ nKid && sizeof ( $ ress ) > 0 ) { $ found = true ; foreach ( $ ress as $ cnt => $ res ) { if ( isset ( $ res [ 2 ] ) && $ res [ 2 ] ) { return 1 ; } } } } } } } return ( ( $ found ) ? - 1 : 0 ) ; }
returns - 1 if nID is a conditional kid and is false
20,426
public function getContentTypeByName ( $ name , $ space , array $ options = [ ] ) { $ envelope = $ this -> findEnvelopeForSpace ( $ space ) ; $ promise = coroutine ( function ( ) use ( $ name , $ space , $ envelope , $ options ) { $ contentTypeFromEnvelope = $ envelope -> findContentTypeByName ( $ name ) ; if ( $ contentTypeFromEnvelope ) { yield promise_for ( $ contentTypeFromEnvelope ) ; return ; } $ contentTypes = ( yield $ this -> getContentTypes ( [ ] , $ space , array_merge ( $ options , [ 'async' => true ] ) ) ) ; $ foundContentType = null ; foreach ( $ contentTypes as $ contentType ) { if ( $ contentType -> getName ( ) === $ name ) { $ foundContentType = $ contentType ; } $ envelope -> insertContentType ( $ contentType ) ; } yield $ foundContentType ; } ) ; return ( isset ( $ options [ 'async' ] ) && $ options [ 'async' ] ) ? $ promise : $ promise -> wait ( ) ; }
Gets a content type using its name . Assumes content types have unique names . Returns null if no content type with the given name can be found .
20,427
public function flushCache ( $ spaceName ) { $ spaceData = $ this -> getSpaceDataForName ( $ spaceName ) ; return $ this -> ensureCache ( $ spaceData [ 'cache' ] ) -> clear ( ) ; }
Flushes the whole cache . Returns true if flush was successful false otherwise .
20,428
private function completeParameter ( ParameterInterface $ parameter , $ spaceName ) { if ( ! $ parameter instanceof IncompleteParameterInterface ) { return $ parameter ; } switch ( $ parameter -> getName ( ) ) { case 'content_type_name' : $ contentTypeFilter = $ this -> resolveContentTypeNameFilter ( $ parameter , $ spaceName ) ; if ( null === $ contentTypeFilter ) { throw new \ RuntimeException ( sprintf ( 'Could not resolve content type with name "%s".' , $ parameter -> getValue ( ) ) ) ; } return $ contentTypeFilter ; break ; default : throw new \ LogicException ( sprintf ( 'Unknown incomplete parameter of type "%s" is being used.' , $ parameter -> getName ( ) ) ) ; break ; } }
Ensures that the provided parameter is complete .
20,429
protected function parseRequest ( RequestInterface $ request , MethodAbstract $ method ) { if ( $ method -> hasRequest ( ) ) { $ schema = $ method -> getRequest ( ) ; if ( $ schema instanceof Passthru ) { $ data = $ this -> requestReader -> getBody ( $ request ) ; } elseif ( $ schema instanceof SchemaInterface ) { $ data = $ this -> requestReader -> getBodyAs ( $ request , $ method -> getRequest ( ) , $ this -> getValidator ( $ method ) ) ; } else { $ data = new Record ( ) ; } } else { $ data = null ; } return $ data ; }
Imports the request data based on the schema if available
20,430
private function sendResponse ( MethodAbstract $ method , RequestInterface $ request , ResponseInterface $ response , $ data ) { $ statusCode = $ response -> getStatusCode ( ) ; if ( empty ( $ statusCode ) ) { $ responses = $ method -> getResponses ( ) ; if ( count ( $ responses ) == 1 ) { $ statusCode = key ( $ responses ) ; } else { $ statusCode = 200 ; } $ response -> setStatus ( $ statusCode ) ; } $ this -> responseWriter -> setBody ( $ response , $ data , $ request ) ; }
Checks whether a response schema is defined for the provided status code and writes the data to the body if a status code is available . Otherwise the API returns 204 no content
20,431
private function getResource ( ) { $ resource = $ this -> resourceListing -> getResource ( $ this -> context -> getPath ( ) , $ this -> context -> getVersion ( ) ) ; if ( ! $ resource instanceof Resource ) { throw new StatusCode \ InternalServerErrorException ( 'Resource is not available' ) ; } return $ resource ; }
Returns the resource from the listing for the current path
20,432
public function getField ( $ fieldId ) { $ resolved = $ this -> getResolved ( ) ; if ( ! $ resolved instanceof ContentTypeInterface ) { return null ; } return $ resolved -> getField ( $ fieldId ) ; }
Returns the content type field matching the passed ID or null if field does not exist .
20,433
public function get ( string $ key = null , $ default = null ) { $ key = \ str_replace ( '.' , '/user-' , $ key ) ; $ value = Arr :: get ( $ this -> items , $ key ) ; if ( $ value === ':to-be-deleted:' ) { return \ value ( $ default ) ; } if ( ! \ is_null ( $ value ) ) { return $ value ; } if ( \ is_null ( $ value = $ this -> handler -> retrieve ( $ key ) ) ) { return \ value ( $ default ) ; } $ this -> put ( $ key , $ value ) ; return $ value ; }
Get value of a key .
20,434
protected function isJson ( $ string ) { $ output = json_decode ( $ string , true ) ; if ( $ output === null ) { return false ; } return true ; }
Checks to see if a string is valid json or not .
20,435
protected static function getTemplate ( $ path ) { if ( file_exists ( $ path ) ) $ template = file_get_contents ( $ path ) ; elseif ( file_exists ( __DIR__ . '/templates/' . $ path ) ) $ template = file_get_contents ( __DIR__ . '/templates/' . $ path ) ; else throw new \ InvalidArgumentException ( 'Template file not found.' ) ; return $ template ; }
Tries to load the content of a template file in path . If this is not possible an exception is thrown .
20,436
public function read ( $ sessionId ) { $ sessionId = $ this -> keyPrefix . $ sessionId ; $ sessionData = $ this -> redis -> get ( $ sessionId ) ; $ this -> redis -> expire ( $ sessionId , $ this -> maxLifetime ) ; return $ sessionData ; }
Read the session data from Redis .
20,437
public function removeForRedirect ( Redirect $ redirect ) { $ notFounds = $ this -> om -> getRepository ( $ this -> class ) -> findBy ( array ( 'path' => $ redirect -> getSource ( ) ) ) ; foreach ( $ notFounds as $ notFound ) { $ this -> om -> remove ( $ notFound ) ; } $ this -> om -> flush ( ) ; }
Deletes NotFound entities for a Redirect s path .
20,438
public function getRef ( $ nodeVersionId ) { $ this -> initNodeVersions ( ) ; return isset ( $ this -> refs [ $ nodeVersionId ] ) ? $ this -> refs [ $ nodeVersionId ] : null ; }
Gets Page Id for given NodeVersion Id
20,439
public function getNodeRef ( $ nodeId , $ lang = null ) { $ this -> initNodeVersions ( ) ; $ lang = $ lang ? : $ this -> currentLocale -> getCurrentLocale ( ) ; return isset ( $ this -> nodeRefs [ $ lang ] [ $ nodeId ] ) ? $ this -> nodeRefs [ $ lang ] [ $ nodeId ] : null ; }
Gets Page Id for given Node Id
20,440
public function read ( $ filePath ) { $ this -> rawEntries = array ( ) ; $ this -> currentEntry = $ this -> createNewEntryAsArray ( ) ; $ this -> state = null ; $ this -> justNewEntry = false ; $ handle = $ this -> openFile ( $ filePath ) ; while ( ! feof ( $ handle ) ) { $ line = trim ( fgets ( $ handle ) ) ; $ this -> processLine ( $ line ) ; } fclose ( $ handle ) ; $ this -> addFinalEntry ( ) ; $ this -> prepareResults ( ) ; return $ this -> entriesAsArrays ; }
Reads and parses strings in a . po file .
20,441
protected function prepareResults ( ) { $ this -> entriesAsArrays = array ( ) ; $ this -> entries = array ( ) ; $ this -> headers = array ( ) ; $ counter = 0 ; foreach ( $ this -> rawEntries as $ entry ) { $ entry = $ this -> prepareEntry ( $ entry , $ counter ) ; $ id = $ this -> getMsgId ( $ entry ) ; $ this -> entriesAsArrays [ $ id ] = $ entry ; $ this -> entries [ $ id ] = new Entry ( $ entry ) ; $ counter ++ ; } return true ; }
Cleanup data merge multiline entries reindex hash for ksort
20,442
protected function removeFuzzyFlagForMsgId ( $ msgid ) { if ( ! isset ( $ this -> entriesAsArrays [ $ msgid ] ) ) { throw new \ Exception ( 'Entry does not exist' ) ; } if ( $ this -> entriesAsArrays [ $ msgid ] [ 'fuzzy' ] ) { $ flags = $ this -> entriesAsArrays [ $ msgid ] [ 'flags' ] ; unset ( $ flags [ array_search ( 'fuzzy' , $ flags , true ) ] ) ; $ this -> entriesAsArrays [ $ msgid ] [ 'flags' ] = $ flags ; $ this -> entriesAsArrays [ $ msgid ] [ 'fuzzy' ] = false ; } }
Helper for the update - functions by deleting the fuzzy flag
20,443
public function updateEntries ( $ msgid , $ translation ) { if ( ! isset ( $ this -> entriesAsArrays [ $ msgid ] ) || ! is_array ( $ translation ) || sizeof ( $ translation ) != sizeof ( $ this -> entriesAsArrays [ $ msgid ] [ 'msgstr' ] ) ) { throw new \ Exception ( 'Cannot update entry translation' ) ; } $ this -> removeFuzzyFlagForMsgId ( $ msgid ) ; $ this -> entriesAsArrays [ $ msgid ] [ 'msgstr' ] = $ translation ; }
Allows modification of all translations of an entry
20,444
public function updateEntry ( $ msgid , $ translation , $ positionMsgstr = 0 ) { if ( ! isset ( $ this -> entriesAsArrays [ $ msgid ] ) || ! is_string ( $ translation ) || ! isset ( $ this -> entriesAsArrays [ $ msgid ] [ 'msgstr' ] [ $ positionMsgstr ] ) ) { throw new \ Exception ( 'Cannot update entry translation' ) ; } $ this -> removeFuzzyFlagForMsgId ( $ msgid ) ; $ this -> entriesAsArrays [ $ msgid ] [ 'msgstr' ] [ $ positionMsgstr ] = $ translation ; }
Allows modification of a single translation of an entry
20,445
public function manualMySql ( Request $ request ) { $ this -> admControlInit ( $ request , '/dashboard/db/all' ) ; if ( $ this -> v [ "uID" ] == 1 ) { $ this -> v [ "manualMySql" ] = 'Connected successfully<br />' ; $ db = mysqli_connect ( env ( 'DB_HOST' , 'localhost' ) , env ( 'DB_USERNAME' , 'homestead' ) , env ( 'DB_PASSWORD' , 'secret' ) , env ( 'DB_DATABASE' , 'homestead' ) ) ; if ( $ db -> connect_error ) { $ this -> v [ "manualMySql" ] = "Connection failed: " . $ db -> connect_error . '<br />' ; } $ this -> v [ "lastSql" ] = '' ; $ this -> v [ "lastResults" ] = [ ] ; if ( $ request -> has ( 'mys' ) && trim ( $ request -> mys ) != '' ) { $ this -> v [ "lastSql" ] = trim ( $ request -> mys ) ; $ this -> v [ "manualMySql" ] .= '<b>Statements submitted...</b><br />' ; $ statements = $ GLOBALS [ "SL" ] -> mexplode ( ';' , $ request -> mys ) ; foreach ( $ statements as $ sql ) { $ cnt = 0 ; if ( trim ( $ sql ) != '' ) { ob_start ( ) ; $ res = mysqli_query ( $ db , $ sql ) ; $ errorCatch = ob_get_contents ( ) ; ob_end_clean ( ) ; $ this -> v [ "lastResults" ] [ $ cnt ] [ 0 ] = $ sql ; $ this -> v [ "lastResults" ] [ $ cnt ] [ 1 ] = $ errorCatch ; if ( $ res -> isNotEmpty ( ) ) { ob_start ( ) ; print_r ( $ res ) ; $ this -> v [ "lastResults" ] [ $ cnt ] [ 2 ] = ob_get_contents ( ) ; ob_end_clean ( ) ; } $ cnt ++ ; } } } mysqli_close ( $ db ) ; return view ( 'vendor.survloop.admin.db.manualMySql' , $ this -> v ) ; } return $ this -> redir ( '/dashboard/db/export' ) ; }
for emergency cases with questionable database access this should only be temporarily included
20,446
public function getOriginalMetaData ( string $ key , $ default = null ) { $ meta = $ this -> accessMetableAttribute ( $ this -> getOriginal ( 'meta' ) ) ; return $ meta -> get ( $ key , $ default ) ; }
Get original meta data .
20,447
public function getMetaData ( string $ key , $ default = null ) { $ meta = $ this -> getAttribute ( 'meta' ) ; return $ meta -> get ( $ key , $ default ) ; }
Get meta data .
20,448
public function putMetaData ( $ key , $ value = null ) : void { $ meta = $ this -> getAttribute ( 'meta' ) ; if ( \ is_array ( $ key ) ) { foreach ( $ key as $ name => $ value ) { $ meta -> put ( $ name , $ value ) ; } } else { $ meta -> put ( $ key , $ value ) ; } $ this -> setMetaAttribute ( $ meta ) ; }
Put meta data .
20,449
public function forgetMetaData ( $ key ) : void { $ meta = $ this -> getAttribute ( 'meta' ) ; if ( \ is_array ( $ key ) ) { foreach ( $ key as $ name ) { $ meta -> forget ( $ name ) ; } } else { $ meta -> forget ( $ key ) ; } $ this -> setMetaAttribute ( $ meta ) ; }
Forget meta data .
20,450
protected function accessMetableAttribute ( $ value ) : Meta { $ meta = [ ] ; if ( $ value instanceof Meta ) { return $ value ; } elseif ( ! \ is_null ( $ value ) ) { $ meta = $ this -> fromJson ( $ value ) ; } return new Meta ( $ meta ) ; }
Access meta attribute .
20,451
public function updateTreeOpts ( $ treeID = - 3 ) { $ treeRow = $ GLOBALS [ "SL" ] -> treeRow ; if ( $ treeID <= 0 ) { $ treeID = $ GLOBALS [ "SL" ] -> treeID ; } else { $ treeRow = SLTree :: find ( $ treeID ) ; } if ( $ treeRow -> TreeType == 'Page' ) { } return true ; }
If none of this tree s nodes have conditions this tree s cache is the most basic
20,452
static function shard ( $ collector = null ) { if ( func_num_args ( ) ) { if ( $ collector ) { static :: $ _shards [ static :: class ] = $ collector ; } else { unset ( static :: $ _shards [ static :: class ] ) ; } return ; } if ( ! isset ( static :: $ _shards [ static :: class ] ) ) { static :: $ _shards [ static :: class ] = new Map ( ) ; } return static :: $ _shards [ static :: class ] ; }
Get the shard attached to the model .
20,453
public static function find ( $ options = [ ] ) { $ options = Set :: extend ( static :: query ( ) , $ options ) ; $ schema = static :: definition ( ) ; return $ schema -> query ( [ 'query' => $ options ] + [ 'finders' => static :: finders ( ) ] ) ; }
Finds a record by its primary key .
20,454
public static function load ( $ id , $ options = [ ] , $ fetchOptions = [ ] ) { $ options = [ 'conditions' => [ static :: definition ( ) -> key ( ) => $ id ] ] + $ options ; return static :: find ( $ options ) -> first ( $ fetchOptions ) ; }
Finds a record by its ID .
20,455
public static function reset ( ) { unset ( static :: $ _dependencies [ static :: class ] ) ; static :: conventions ( null ) ; static :: connection ( null ) ; static :: definition ( null ) ; static :: validator ( null ) ; static :: query ( [ ] ) ; unset ( static :: $ _unicities [ static :: class ] ) ; unset ( static :: $ _definitions [ static :: class ] ) ; unset ( static :: $ _shards [ static :: class ] ) ; }
Reset the Model class .
20,456
public function fetch ( $ name ) { return $ this -> get ( $ name , function ( $ instance , $ name ) { $ collection = [ $ instance ] ; $ this -> schema ( ) -> embed ( $ collection , $ name ) ; return isset ( $ this -> _data [ $ name ] ) ? $ this -> _data [ $ name ] : null ; } ) ; }
Lazy load a relation and return its data .
20,457
public function sync ( $ data = false ) { if ( $ this -> _exists !== null ) { return ; } $ id = $ this -> id ( ) ; if ( $ id !== null ) { $ persisted = static :: load ( $ id ) ; if ( $ persisted && $ data ) { $ this -> amend ( $ persisted -> data ( ) , [ 'exists' => true ] ) ; } else { $ this -> _exists = ! ! $ persisted ; } } else { $ this -> _exists = false ; } }
Sync the entity existence from the database .
20,458
public function validates ( $ options = [ ] ) { $ this -> sync ( ) ; $ exists = $ this -> exists ( ) ; $ defaults = [ 'events' => $ exists ? 'update' : 'create' , 'required' => $ exists ? false : true , 'entity' => $ this , 'embed' => true ] ; $ options += $ defaults ; $ validator = static :: validator ( ) ; $ valid = $ this -> _validates ( [ 'embed' => $ options [ 'embed' ] ] ) ; $ success = $ validator -> validates ( $ this -> get ( ) , $ options ) ; $ this -> _errors = [ ] ; $ this -> invalidate ( $ validator -> errors ( ) ) ; return $ success && $ valid ; }
Validates the entity data .
20,459
protected function _validates ( $ options ) { $ defaults = [ 'embed' => true ] ; $ options += $ defaults ; if ( $ options [ 'embed' ] === true ) { $ options [ 'embed' ] = $ this -> hierarchy ( ) ; } $ schema = $ this -> schema ( ) ; $ tree = $ schema -> treeify ( $ options [ 'embed' ] ) ; $ success = true ; foreach ( $ tree as $ field => $ value ) { if ( isset ( $ this -> { $ field } ) ) { $ rel = $ schema -> relation ( $ field ) ; $ success = $ success && $ rel -> validates ( $ this , $ value ? $ value + $ options : $ options ) ; } } return $ success ; }
Check if nested relations are valid .
20,460
public function invalidate ( $ field , $ errors = [ ] ) { $ schema = $ this -> schema ( ) ; if ( func_num_args ( ) === 1 ) { foreach ( $ field as $ key => $ value ) { if ( $ schema -> hasRelation ( $ key ) && $ this -> has ( $ key ) ) { $ this -> { $ key } -> invalidate ( $ value ) ; } else { $ this -> invalidate ( $ key , $ value ) ; } } return $ this ; } if ( $ errors ) { $ this -> _errors [ $ field ] = ( array ) $ errors ; } return $ this ; }
Invalidate a field or an array of fields .
20,461
public function error ( $ field , $ all = false ) { if ( ! empty ( $ this -> _errors [ $ field ] ) ) { return $ all ? $ this -> _errors [ $ field ] : reset ( $ this -> _errors [ $ field ] ) ; } return '' ; }
Return an indivitual error
20,462
public function errored ( $ field = null ) { if ( ! func_num_args ( ) ) { return ! ! $ this -> _errors ; } return isset ( $ this -> _errors [ $ field ] ) ; }
Check if the entity or a specific field errored
20,463
public function bindColumn ( $ column , & $ param , $ type = PDO :: PARAM_STR , $ maxlen = - 1 , $ driverdata = null ) { $ type = $ this -> removeBitFlag ( $ $ type , PDO :: PARAM_INPUT_OUTPUT ) ; $ ociParamType = $ this -> pdo2OciParamConst ( $ type ) ; if ( $ lob_desc = $ this -> oci_lob_desc ( $ ociParamType ) ) { $ this -> _lobs [ $ this -> _lobsCount ] [ 'type' ] = $ ociParamType ; $ this -> _lobs [ $ this -> _lobsCount ] [ 'lob' ] = @ oci_new_descriptor ( $ this -> ociPdoAdapter -> getOciConnection ( ) , $ lob_desc ) ; $ res = $ this -> _lobs [ $ this -> _lobsCount ] [ 'lob' ] ; $ this -> checkError ( $ res ) ; $ res = @ oci_define_by_name ( $ this -> stmt , $ column , $ this -> _lobs [ $ this -> _lobsCount ] [ 'lob' ] , $ ociParamType ) ; $ this -> checkError ( $ res ) ; $ this -> _lobs [ $ this -> _lobsCount ] [ 'var' ] = $ param ; $ this -> _lobs [ $ this -> _lobsCount ] [ 'input' ] = false ; $ this -> _lobsCount ++ ; } else { $ res = @ oci_define_by_name ( $ this -> stmt , $ column , $ param , $ ociParamType ) ; $ this -> checkError ( $ res ) ; } return $ res ; }
Binds a column to a PHP variable
20,464
public function fetchObject ( $ class_name = 'stdClass' , array $ ctor_args = array ( ) ) { $ obj = $ this -> fetch ( PDO :: FETCH_OBJ ) ; if ( $ class_name == 'stdClass' ) { $ res = $ obj ; } else { $ res = $ this -> populateObject ( $ obj , $ class_name , $ ctor_args ) ; } return $ res ; }
Fetches the next row and returns it as an object
20,465
protected function getError ( ) { if ( $ this -> _error === false ) { if ( is_resource ( $ this -> stmt ) ) { $ this -> _error = @ oci_error ( $ this -> stmt ) ; } else { $ this -> _error = @ oci_error ( ) ; } } return $ this -> _error ; }
Retrieve OCI error of the statement
20,466
public function oci_lob_desc ( $ type ) { switch ( $ type ) { case OCI_B_BFILE : $ result = OCI_D_FILE ; break ; case OCI_B_CFILEE : $ result = OCI_D_FILE ; break ; case OCI_B_CLOB : case SQLT_CLOB : case OCI_B_BLOB : case SQLT_BLOB : $ result = OCI_D_LOB ; break ; case OCI_B_ROWID : $ result = OCI_D_ROWID ; break ; default : $ result = false ; break ; } return $ result ; }
Define the LOB descriptor type for the given type
20,467
protected function lobToStream ( & $ lob ) { if ( is_null ( $ lob ) ) { return null ; } if ( is_object ( $ lob ) && get_class ( $ lob ) == 'OCI-Lob' ) { return fopen ( 'ocipdolob://' , 'r' , false , OciPdoLobStreamWrapper :: getContext ( $ lob ) ) ; } else { return String2Stream :: create ( $ lob ) ; } }
Convert string or OCI LOB to stream
20,468
public static function parse ( $ doc ) { $ block = new DocBlock ( ) ; $ lines = explode ( "\n" , $ doc ) ; unset ( $ lines [ 0 ] ) ; foreach ( $ lines as $ line ) { $ line = trim ( $ line ) ; $ line = substr ( $ line , 2 ) ; if ( isset ( $ line [ 0 ] ) && $ line [ 0 ] == '@' ) { $ line = substr ( $ line , 1 ) ; $ sp = strpos ( $ line , ' ' ) ; $ bp = strpos ( $ line , '(' ) ; if ( $ sp !== false || $ bp !== false ) { if ( $ sp !== false && $ bp === false ) { $ pos = $ sp ; } elseif ( $ sp === false && $ bp !== false ) { $ pos = $ bp ; } else { $ pos = $ sp < $ bp ? $ sp : $ bp ; } $ key = substr ( $ line , 0 , $ pos ) ; $ value = substr ( $ line , $ pos ) ; } else { $ key = $ line ; $ value = null ; } $ key = trim ( $ key ) ; $ value = trim ( $ value ) ; if ( ! empty ( $ key ) ) { $ pos = strrpos ( $ key , '\\' ) ; if ( $ pos !== false ) { $ key = substr ( $ key , $ pos + 1 ) ; } $ block -> addAnnotation ( $ key , $ value ) ; } } } return $ block ; }
Parses the annotations from the given doc block
20,469
public static function parseAttributes ( $ values ) { $ result = array ( ) ; $ values = trim ( $ values , " \t\n\r\0\x0B()" ) ; $ parts = explode ( ',' , $ values ) ; foreach ( $ parts as $ part ) { $ kv = explode ( '=' , $ part , 2 ) ; $ key = trim ( $ kv [ 0 ] ) ; $ value = isset ( $ kv [ 1 ] ) ? $ kv [ 1 ] : '' ; $ value = trim ( $ value , " \t\n\r\0\x0B\"" ) ; if ( ! empty ( $ key ) ) { $ result [ $ key ] = $ value ; } } return $ result ; }
Parses the constructor values from an doctrine annotation
20,470
protected function loadMapRow ( ) { $ ret = [ "cnt" => 0 , "rec" => [ ] , "dat" => [ ] ] ; if ( sizeof ( $ this -> datMap ) > 0 ) { foreach ( $ this -> datMap as $ let => $ d ) { $ ret [ "dat" ] [ $ let ] = [ "sum" => 0 , "avg" => 0 , "ids" => [ ] ] ; } } return $ ret ; }
raw data array filters on each raw data point data sum data average unique record count
20,471
protected function _merge ( $ data , $ exists ) { if ( ! $ data ) { $ this -> _parent -> get ( $ this -> _through ) -> clear ( ) ; return ; } $ pivot = $ this -> _parent -> { $ this -> _through } ; $ relThrough = $ this -> _parent -> schema ( ) -> relation ( $ this -> _through ) ; $ through = $ relThrough -> to ( ) ; $ schema = $ through :: definition ( ) ; $ rel = $ schema -> relation ( $ this -> _using ) ; $ fromKey = $ rel -> keys ( 'from' ) ; $ toKey = $ rel -> keys ( 'to' ) ; $ i = 0 ; while ( $ i < $ pivot -> count ( ) ) { $ found = false ; $ entity = $ pivot -> get ( $ i ) ; $ id1 = $ entity -> get ( $ fromKey ) ; if ( $ id1 === null ) { $ pivot -> splice ( $ i , 1 ) ; continue ; } foreach ( $ data as $ key => $ item ) { $ isDocument = $ item instanceof Document ; $ id2 = $ isDocument ? $ item -> get ( $ toKey ) : ( isset ( $ item [ $ toKey ] ) ? $ item [ $ toKey ] : null ) ; if ( ( string ) $ id1 === ( string ) $ id2 ) { if ( $ isDocument ) { $ entity -> set ( $ this -> _using , $ item ) ; } else { $ entity -> get ( $ this -> _using ) -> amend ( $ item ) ; } unset ( $ data [ $ key ] ) ; $ i ++ ; $ found = true ; break ; } } if ( ! $ found ) { $ pivot -> splice ( $ i , 1 ) ; } } foreach ( $ data as $ entity ) { $ this [ ] = $ entity ; } }
Merge pivot data based on entities ids
20,472
public function set ( $ offset = null , $ data = [ ] ) { $ name = $ this -> _through ; $ this -> _parent -> { $ name } -> set ( $ offset , $ this -> _item ( $ data ) ) ; return $ this ; }
Sets data to a specified offset and wraps all data array in its appropriate object type .
20,473
public function push ( $ data = [ ] ) { $ name = $ this -> _through ; $ this -> _parent -> { $ name } -> push ( $ offset , $ this -> _item ( $ data ) ) ; return $ this ; }
Adds data into the Collection instance .
20,474
protected function _item ( $ data , $ options = [ ] ) { $ name = $ this -> _through ; $ parent = $ this -> _parent ; $ relThrough = $ parent -> schema ( ) -> relation ( $ name ) ; $ through = $ relThrough -> to ( ) ; $ id = $ this -> _parent -> id ( ) ; $ item = $ through :: create ( $ id !== null ? $ relThrough -> match ( $ this -> _parent ) : [ ] , $ options ) ; $ item -> setAt ( $ this -> _using , $ data , $ options ) ; return $ item ; }
Create a pivot instance .
20,475
public function prev ( ) { $ entity = $ this -> _parent -> { $ this -> _through } -> prev ( ) ; if ( $ entity ) { return $ entity -> { $ this -> _using } ; } }
Moves backward to the previous item . If already at the first item moves to the last one .
20,476
public function map ( $ closure ) { $ data = [ ] ; foreach ( $ this as $ val ) { $ data [ ] = $ closure ( $ val ) ; } return new Collection ( compact ( 'data' ) ) ; }
Applies a closure to a copy of all data in the collection and returns the result .
20,477
public function reduce ( $ closure , $ initial = false ) { $ result = $ initial ; foreach ( $ this as $ val ) { $ result = $ closure ( $ result , $ val ) ; } return $ result ; }
Reduces or folds a collection down to a single value
20,478
public function validates ( $ options = [ ] ) { $ success = true ; foreach ( $ this as $ entity ) { if ( ! $ entity -> validates ( $ options ) ) { $ success = false ; } } return $ success ; }
Validates the collection .
20,479
public function color ( $ color = null , $ style = null , $ background = null ) { $ colors = $ this -> getColorCodes ( ) ; if ( is_array ( $ color ) ) { $ style = isset ( $ color [ 'style' ] ) ? $ color [ 'style' ] : null ; $ background = isset ( $ color [ 'background' ] ) ? $ color [ 'background' ] : null ; $ color = isset ( $ color [ 'color' ] ) ? $ color [ 'color' ] : null ; } if ( $ color == 'reset' ) { return "\033[0m" ; } $ code = array ( ) ; if ( isset ( $ style ) ) { $ code [ ] = $ colors [ 'style' ] [ $ style ] ; } if ( isset ( $ color ) ) { $ code [ ] = $ colors [ 'color' ] [ $ color ] ; } if ( isset ( $ background ) ) { $ code [ ] = $ colors [ 'background' ] [ $ background ] ; } if ( empty ( $ code ) ) { $ code [ ] = 0 ; } $ code = implode ( ';' , $ code ) ; return "\033[{$code}m" ; }
Returns an ANSI - Controlcode
20,480
protected function formatExceptionMsg ( $ exceptionMessage ) { $ exceptionMessage = str_replace ( "+++ Actual\n" , '' , $ exceptionMessage ) ; $ exceptionMessage = str_replace ( "--- Expected\n" , '' , $ exceptionMessage ) ; $ exceptionMessage = str_replace ( "@@ @@\n" , '' , $ exceptionMessage ) ; $ exceptionMessage = preg_replace ( "/(Failed.*)$/m" , " \033[01;31m$1\033[0m" , $ exceptionMessage ) ; $ exceptionMessage = preg_replace ( "/\-+(.*)$/m" , "\n \033[01;32m$1\033[0m" , $ exceptionMessage ) ; return preg_replace ( "/\++(.*)$/m" , " \033[01;31m$1\033[0m" , $ exceptionMessage ) ; }
Add colors and removes superfluous informations
20,481
public function attachRoles ( $ roles ) { if ( $ roles instanceof Role ) { $ roles = [ $ roles -> getKey ( ) ] ; } $ this -> roles ( ) -> sync ( $ roles , false ) ; unset ( $ this -> relations [ 'roles' ] ) ; return $ this ; }
Assign roles to user .
20,482
public function detachRoles ( $ roles ) { if ( $ roles instanceof Role ) { $ roles = [ $ roles -> getKey ( ) ] ; } $ this -> roles ( ) -> detach ( $ roles ) ; unset ( $ this -> relations [ 'roles' ] ) ; return $ this ; }
Un - assign roles from user .
20,483
public static function make ( ? string $ salt , ? int $ length , ? string $ alphabet ) { $ salt = is_null ( $ salt ) ? config ( 'hashids.salt' ) : config ( 'hashids.salt' ) . $ salt ; $ length = $ length ?? config ( 'hashids.length' ) ; $ alphabet = $ alphabet ?? config ( 'hashids.alphabet' ) ; $ salt = \ Illuminate \ Support \ Facades \ Hash :: make ( $ salt ) ; return new self ( $ salt , $ length , $ alphabet ) ; }
Create an instance of Hashids .
20,484
public static function configureAsRoot ( ) : void { $ filesystem = new Filesystem ( ) ; $ vendor_dir = Path :: VENDOR_DIR . '/hostnet/phpcs-tool/src' ; if ( $ filesystem -> exists ( $ vendor_dir ) ) { return ; } self :: configure ( ) ; $ filesystem -> mkdir ( $ vendor_dir . '/Hostnet' ) ; $ filesystem -> symlink ( __DIR__ . '/../../Sniffs' , $ vendor_dir . '/Hostnet/Sniffs' ) ; $ filesystem -> copy ( __DIR__ . '/../../ruleset.xml' , $ vendor_dir . '/Hostnet/ruleset.xml' ) ; $ filesystem -> mkdir ( $ vendor_dir . '/HostnetPaths' ) ; $ filesystem -> copy ( __DIR__ . '/../../../HostnetPaths/ruleset.xml' , $ vendor_dir . '/HostnetPaths/ruleset.xml' ) ; }
Configuration for standalone use in a system wide installation scenario
20,485
public function execute ( ) : void { self :: configure ( ) ; if ( false === $ this -> io -> isVerbose ( ) ) { return ; } $ this -> io -> write ( '<info>Configured phpcs to use Hostnet standard</info>' ) ; }
The logical - operation of this Installer . PHPCS does not define constants for the config options doing so ourselves would only lead to outdated intel .
20,486
public static function configure ( ) : void { $ filesystem = new Filesystem ( ) ; $ config = [ 'colors' => '1' , 'installed_paths' => implode ( ',' , [ Path :: VENDOR_DIR . '/hostnet/phpcs-tool/src/' , Path :: VENDOR_DIR . '/slevomat/coding-standard/SlevomatCodingStandard' , ] ) , ] ; if ( ! $ filesystem -> exists ( [ 'phpcs.xml' , 'phpcs.xml.dist' ] ) ) { $ config [ 'default_standard' ] = 'Hostnet' ; } $ filesystem -> dumpFile ( Path :: VENDOR_DIR . '/squizlabs/php_codesniffer/CodeSniffer.conf' , sprintf ( '<?php $phpCodeSnifferConfig = %s;' , var_export ( $ config , true ) ) ) ; $ filesystem -> dumpFile ( __DIR__ . '/../../../HostnetPaths/ruleset.xml' , self :: generateHostnetPathsXml ( ) ) ; }
Configure the Hostnet code style
20,487
public function configure ( $ _array = NULL ) { if ( $ _array != NULL ) { if ( isset ( $ _array [ 'x' ] ) ) $ this -> _config [ 'x' ] = $ _array [ 'x' ] ; if ( isset ( $ _array [ 'y' ] ) ) $ this -> _config [ 'y' ] = $ _array [ 'y' ] ; if ( isset ( $ _array [ 'w' ] ) ) $ this -> _config [ 'w' ] = $ _array [ 'w' ] ; if ( isset ( $ _array [ 'h' ] ) ) $ this -> _config [ 'h' ] = $ _array [ 'h' ] ; if ( isset ( $ _array [ 'f' ] ) ) $ this -> _config [ 'f' ] = $ _array [ 'f' ] ; } return self :: $ _instance ; }
configure the attribute of the Verify code .
20,488
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ output -> writeln ( '<info>Welcome to the Cypress GitElephantBundle merge command.</info>' ) ; if ( $ input -> getOption ( 'no-push' ) ) { $ output -> writeln ( '<comment>--no-push option enabled (this option disable push destination branch to remotes)</comment>' ) ; } $ rc = $ this -> getContainer ( ) -> get ( 'git_repositories' ) ; if ( $ rc -> count ( ) == 0 ) { throw new \ Exception ( 'Must have at least one Git repository. See https://github.com/matteosister/GitElephantBundle#how-to-use' ) ; } foreach ( $ rc as $ key => $ repository ) { if ( $ key == 0 || $ key > 0 && $ input -> getOption ( 'all' ) ) { $ source = $ repository -> getBranch ( $ input -> getArgument ( 'source' ) ) ; if ( is_null ( $ source ) ) { throw new \ Exception ( 'Source branch ' . $ input -> getArgument ( 'source' ) . ' doesn\'t exists' ) ; } $ destination = $ repository -> getBranch ( $ input -> getArgument ( 'destination' ) ) ; if ( is_null ( $ destination ) ) { throw new \ Exception ( 'Destination branch ' . $ input -> getArgument ( 'destination' ) . ' doesn\'t exists' ) ; } $ repository -> checkout ( $ destination -> getName ( ) ) ; $ repository -> merge ( $ source , '' , ( ! $ input -> getOption ( 'fast-forward' ) ? 'no-ff' : 'ff-only' ) ) ; if ( ! $ input -> getOption ( 'no-push' ) ) { foreach ( $ repository -> getRemotes ( ) as $ remote ) { $ repository -> push ( $ remote -> getName ( ) , $ repository -> getMainBranch ( ) -> getName ( ) ) ; } } $ repository -> checkout ( $ input -> getArgument ( 'source' ) ) ; $ output -> writeln ( 'Merge from ' . $ input -> getArgument ( 'source' ) . ' branch to ' . $ input -> getArgument ( 'destination' ) . ' done' . ( ! $ input -> getOption ( 'no-push' ) ? ' and pushed to all remotes.' : '' ) ) ; } } }
Execute merge command
20,489
public function getSearchableRules ( ) : array { return [ 'roles:[]' => function ( Builder $ query , array $ roles ) { return $ query -> whereHas ( 'roles' , function ( Builder $ query ) use ( $ roles ) { return $ query -> whereIn ( Role :: column ( 'name' ) , $ roles ) ; } ) ; } , ] ; }
Get searchable rules .
20,490
public function scopeHasRoles ( Builder $ query , array $ roles = [ ] ) : Builder { $ query -> with ( 'roles' ) -> whereNotNull ( 'users.id' ) ; if ( ! empty ( $ roles ) ) { $ query -> whereHas ( 'roles' , function ( $ query ) use ( $ roles ) { $ query -> whereIn ( Role :: column ( 'name' ) , $ roles ) ; } ) ; } return $ query ; }
Search user based on keyword as roles .
20,491
public function scopeHasRolesId ( Builder $ query , array $ rolesId = [ ] ) : Builder { $ query -> with ( 'roles' ) -> whereNotNull ( 'users.id' ) ; if ( ! empty ( $ rolesId ) ) { $ query -> whereHas ( 'roles' , function ( $ query ) use ( $ rolesId ) { $ query -> whereIn ( Role :: column ( 'id' ) , $ rolesId ) ; } ) ; } return $ query ; }
Search user based on keyword as roles id .
20,492
public function setPasswordAttribute ( string $ value ) : void { if ( Hash :: needsRehash ( $ value ) ) { $ value = Hash :: make ( $ value ) ; } $ this -> attributes [ 'password' ] = $ value ; }
Set password mutator .
20,493
public function scopeOwnedBy ( Builder $ query , Model $ related , ? string $ key = null ) : Builder { if ( \ is_null ( $ key ) ) { $ key = $ related -> getForeignKey ( ) ; } return $ query -> where ( $ key , $ related -> getKey ( ) ) ; }
Scope query to get model which are owned by the specified model .
20,494
private function getEncoding ( string & $ string ) : string { if ( substr ( $ string , 0 , 3 ) === self :: UTF8 ) { $ string = substr ( $ string , 3 ) ; return self :: UTF8 ; } if ( substr ( $ string , 0 , 2 ) === self :: UTF16BE ) { $ string = substr ( $ string , 2 ) ; return self :: UTF16BE ; } if ( substr ( $ string , 0 , 2 ) === self :: UTF16LE ) { $ string = substr ( $ string , 2 ) ; return self :: UTF16LE ; } return self :: UNKNOWN ; }
Get the encoding of a BOM declared string and remove the bom .
20,495
public function convert ( string $ string ) : string { if ( $ this -> encoding === null ) { $ this -> encoding = $ this -> getEncoding ( $ string ) ; } if ( $ this -> encoding === self :: UTF16BE ) { $ string = mb_convert_encoding ( $ string , "UTF-8" , "UTF-16BE" ) ; } if ( $ this -> encoding === self :: UTF16LE ) { $ string = mb_convert_encoding ( $ string , "UTF-8" , "UTF-16LE" ) ; } return $ string ; }
Read some data remove any BOM found and convert to UTF - 8 .
20,496
public function set ( $ value , $ data ) { $ id = is_object ( $ value ) ? spl_object_hash ( $ value ) : $ value ; $ this -> _keys [ $ id ] = $ value ; $ this -> _data [ $ id ] = $ data ; return $ this ; }
Collects an object .
20,497
public function get ( $ value ) { $ id = is_object ( $ value ) ? spl_object_hash ( $ value ) : $ value ; if ( isset ( $ this -> _data [ $ id ] ) ) { return $ this -> _data [ $ id ] ; } throw new ORMException ( "No collected data associated to the key." ) ; }
Gets a collected object .
20,498
public function delete ( $ value ) { $ id = is_object ( $ value ) ? spl_object_hash ( $ value ) : $ value ; unset ( $ this -> _keys [ $ id ] ) ; unset ( $ this -> _data [ $ id ] ) ; return $ this ; }
Uncollects an object .
20,499
public function has ( $ value ) { $ id = is_object ( $ value ) ? spl_object_hash ( $ value ) : $ value ; return isset ( $ this -> _data [ $ id ] ) ; }
Checks if an object with a specific ID has already been collected .