idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
44,400 | public function orLike ( $ key , $ like ) { $ value = sprintf ( '%s LIKE ?' , $ key ) ; return $ this -> orAdd ( $ value , [ $ like ] ) ; } | or like condition . |
44,401 | public function orNotLike ( $ key , $ like ) { $ value = sprintf ( '%s NOT LIKE ?' , $ key ) ; return $ this -> orAdd ( $ value , [ $ like ] ) ; } | or not like condition . |
44,402 | private function constructException ( array $ details ) { $ this -> details [ 'argument_value_error' ] [ $ this -> argument ] = $ this -> details [ 'argument_value_error' ] [ 'ARG' ] ; $ this -> details [ 'argument_value_error' ] [ $ this -> argument ] = $ details ; unset ( $ this -> details [ 'argument_value_error' ] [ 'ARG' ] ) ; } | Fill in exception details |
44,403 | public function parseColumnNames ( $ string , ContextAwareInterface $ context = null ) { $ matchArray = [ ] ; preg_match_all ( "#~([a-zA-Z0-9_]\\.{0,1})+#" , $ string , $ matchArray ) ; $ matchArray = array_unique ( $ matchArray [ 0 ] ) ; foreach ( $ matchArray as $ match ) { if ( $ context ) { $ nsMatch = $ context -> getNameInContext ( $ match ) ; } else { $ nsMatch = $ match ; } $ path = ltrim ( $ nsMatch , "~" ) ; $ tablePath = rtrim ( substr ( $ nsMatch , 1 , strrpos ( $ nsMatch , "." ) ) , "." ) ; $ replace = $ this -> _doFQLTableName ( $ tablePath , null , true ) . "." . $ this -> getBaseFace ( ) -> getElement ( $ path ) -> getSqlColumnName ( true ) ; $ string = str_replace ( $ match , $ replace , $ string ) ; } return $ string ; } | replaces the waved string by the sql - valid column name |
44,404 | public function execute ( $ config = null ) { if ( null == $ config ) { $ pdo = Config :: getDefault ( ) -> getPdo ( ) ; } else if ( $ config instanceof \ PDO ) { $ pdo = $ config ; } else if ( $ config instanceof Config ) { $ pdo = $ config -> getPdo ( ) ; } else { throw new BadParameterException ( 'First parameter of FQuery::execute is not correct' ) ; } $ stmt = $ this -> getPdoStatement ( $ pdo ) ; if ( $ stmt -> execute ( ) ) { return $ stmt ; } else { throw new QueryFailedException ( $ stmt ) ; } } | Executes the query from the given pdo object |
44,405 | public function getPdoStatement ( \ PDO $ pdo ) { $ stmt = $ pdo -> prepare ( $ this -> getSqlString ( ) ) ; $ bound = $ this -> getBoundValues ( ) ; foreach ( $ bound as $ name => $ bind ) { $ stmt -> bindValue ( $ name , $ bind [ 0 ] , $ bind [ 1 ] ) ; } return $ stmt ; } | get a statement for the given pdo object values are already bound |
44,406 | public static function __doFQLTableNameStatic ( $ path , $ token = null , $ escape = false ) { if ( null === $ token ) { $ token = self :: $ DOT_TOKEN ; } if ( "this" === $ path || empty ( $ path ) ) { if ( $ escape ) { return "`this`" ; } else { return "this" ; } } if ( ! StringUtils :: beginsWith ( "this." , $ path ) ) { $ path = "this." . $ path ; } $ name = str_replace ( "." , $ token , $ path ) ; if ( $ escape ) { return "`$name`" ; } else { return $ name ; } } | reserved for internal usage |
44,407 | public function handle ( ServerRequestInterface $ request ) : ResponseInterface { $ details = new Inspector ( $ this -> e ) ; $ contents = json_encode ( [ 'type' => get_class ( $ details -> inner ( ) ) , 'message' => $ details -> inner ( ) -> getMessage ( ) , 'context' => [ 'type' => get_class ( $ details -> current ( ) ) , 'message' => $ details -> current ( ) -> getMessage ( ) , ] , 'trace' => $ details -> inner ( ) -> getTrace ( ) , ] ) ; $ response = $ this -> factory -> createResponse ( 500 ) -> withHeader ( 'Content-type' , 'application/json' ) ; $ response -> getBody ( ) -> write ( $ contents ) ; return $ response ; } | Return a detailled json response for the exception . |
44,408 | protected function compileWhereBasic ( $ where ) { extract ( $ where ) ; if ( $ operator == 'like' ) { $ operator = '=' ; $ regex = str_replace ( '%' , '' , $ value ) ; if ( substr ( $ value , 0 , 1 ) != '%' ) $ regex = '^' . $ regex ; if ( substr ( $ value , - 1 ) != '%' ) $ regex = $ regex . '$' ; $ value = array ( '$regex' => "$regex" ) ; } if ( ! isset ( $ operator ) || $ operator == '=' ) { $ query = array ( $ column => $ value ) ; } elseif ( array_key_exists ( $ operator , $ this -> conversion ) ) { $ query = array ( $ column => array ( $ this -> conversion [ $ operator ] => $ value ) ) ; } else { $ query = array ( $ column => array ( '$' . $ operator => $ value ) ) ; } return $ query ; } | Compile the query s where clauses . |
44,409 | public function formatQuery ( array $ data , array $ formatted = array ( ) ) { foreach ( $ data as $ key => $ value ) { array_set ( $ formatted , $ key , $ value ) ; } return $ formatted ; } | Format a query . |
44,410 | public static function getFirstNonEmptyElement ( $ list , $ default = null ) { foreach ( $ list as $ item ) { if ( empty ( $ item ) === false ) { return $ item ; } } return $ default ; } | Get the first non - empty element of a list . |
44,411 | public static function inCsv ( $ item , $ list , $ delimiter = ',' , $ enclosure = '"' , $ escape = '\\' ) { return in_array ( $ item , str_getcsv ( $ list , $ delimiter , $ enclosure , $ escape ) ) ; } | Is an item in a CSV - formatted string list? |
44,412 | public static function i18n ( $ pattern , array $ options = array ( ) ) { $ pattern = rtrim ( $ pattern , '/ ' ) ; $ options = array_merge ( array ( "controller" => "\\ChickenWire\\I18n\\I18nController" ) , $ options ) ; Route :: match ( $ pattern , array_merge ( array ( "action" => "all" ) , $ options ) ) ; Route :: match ( $ pattern . '/current' , array_merge ( array ( "action" => "current" ) , $ options ) ) ; Route :: match ( $ pattern . '/current/{*path}' , array_merge ( array ( "action" => "current" ) , $ options ) ) ; Route :: match ( $ pattern . '/{*path}' , array_merge ( array ( "action" => "all" ) , $ options ) ) ; } | Create a pattern for client - side I18n requests |
44,413 | public static function request ( $ request , & $ httpStatus , & $ urlParams ) { $ status = 404 ; $ foundRoute = null ; $ foundParams = null ; foreach ( self :: $ _routes as $ route ) { if ( $ route -> checked ) continue ; preg_match_all ( $ route -> _regexPattern , $ request -> uri , $ matches ) ; $ route -> checked = true ; if ( count ( $ matches [ 0 ] ) == 1 ) { if ( Arry :: Contains ( $ request -> method , $ route -> methods , false ) ) { $ foundRoute = $ route ; $ status = 200 ; $ foundParams = array ( ) ; if ( count ( $ matches ) > 1 ) { for ( $ q = 1 ; $ q < count ( $ matches ) ; $ q ++ ) { $ foundParams [ ] = $ matches [ $ q ] [ 0 ] ; } } break ; } else { if ( is_null ( $ foundRoute ) || $ status !== 200 ) { $ foundRoute = $ route ; $ status = 405 ; } } } } if ( sizeof ( $ foundParams ) > 0 ) { $ urlParams = array ( ) ; foreach ( $ route -> _patternVariables as $ index => $ varName ) { $ value = $ foundParams [ $ index ] ; if ( substr ( $ varName , 0 , 1 ) == '#' ) { $ value = intval ( $ value ) ; $ varName = substr ( $ varName , 1 ) ; } if ( substr ( $ varName , 0 , 1 ) == '*' ) { $ varName = substr ( $ varName , 1 ) ; } $ urlParams [ $ varName ] = $ value ; } } else { $ urlParams = array ( ) ; } $ httpStatus = $ status ; self :: $ _currentRoute = $ foundRoute ; return $ foundRoute ; } | Match the given request on all configured routes and return first match |
44,414 | public function replaceFields ( $ models ) { $ url = $ this -> _pattern ; foreach ( $ this -> _patternVariables as $ var ) { $ varName = $ var [ 0 ] == '#' ? substr ( $ var , 1 ) : $ var ; if ( strstr ( $ varName , '.' ) ) { list ( $ modelName , $ varName ) = explode ( "." , $ varName ) ; $ model = null ; foreach ( $ models as $ m ) { if ( Str :: removeNamespace ( get_class ( $ m ) ) == $ modelName ) { $ model = $ m ; break ; } } if ( is_null ( $ model ) ) { throw new \ Exception ( "You need to pass an Model instance of $modelName to generate a url for " . $ this -> _pattern , 1 ) ; } } else { $ model = $ models [ count ( $ models ) - 1 ] ; } $ sluggedVarName = $ varName . "Slug" ; if ( $ model -> hasAttribute ( $ sluggedVarName ) ) { $ value = $ model -> $ sluggedVarName ; } else { $ value = $ model -> $ varName ; } $ url = str_replace ( '{' . $ var . '}' , strval ( $ value ) , $ url ) ; } return $ url ; } | Replace fields in the Route with values from the Model instances |
44,415 | protected function startRoutingPlugin ( $ app ) { $ this -> requiresPlugins ( Paths :: class , Resources :: class ) ; $ this -> onRegister ( 'routing' , function ( Application $ app ) { if ( PHP_SAPI !== 'cli' || $ this -> app -> runningUnitTests ( ) ) { $ router = $ app -> make ( 'router' ) ; $ kernel = $ app -> make ( 'Illuminate\Contracts\Http\Kernel' ) ; foreach ( $ this -> prependMiddleware as $ class ) { $ kernel -> prependMiddleware ( $ class ) ; } foreach ( $ this -> middleware as $ class ) { $ kernel -> pushMiddleware ( $ class ) ; } foreach ( $ this -> routeMiddleware as $ name => $ class ) { if ( method_exists ( $ router , 'middleware' ) ) { $ router -> middleware ( $ name , $ class ) ; } else { $ router -> aliasMiddleware ( $ name , $ class ) ; } } foreach ( $ this -> middlewareGroups as $ groupName => $ classes ) { $ router -> middlewareGroup ( $ groupName , $ classes ) ; } foreach ( $ this -> prependGroupMiddleware as $ group => $ class ) { $ router -> prependMiddlewareToGroup ( $ group , $ class ) ; } foreach ( $ this -> groupMiddleware as $ group => $ class ) { $ router -> pushMiddlewareToGroup ( $ group , $ class ) ; } } } ) ; $ this -> onBoot ( 'routing' , function ( Application $ app ) { foreach ( $ this -> routeFiles as $ routeFile ) { $ this -> loadRoutesFrom ( path_join ( $ this -> resolvePath ( 'routesPath' ) , str_ensure_right ( $ routeFile , '.php' ) ) ) ; } } ) ; static :: refreshRoutes ( $ app ) ; } | startMiddlewarePlugin method . |
44,416 | public function getUriForDiagrammType ( $ type ) { switch ( $ type ) { case Diagramm :: TYPE_ACTIVITY : $ uri = $ this -> getOptions ( ) -> getYumlActivityDiagrammUrl ( ) ; break ; case Diagramm :: TYPE_CLASS : $ uri = $ this -> getOptions ( ) -> getYumlClassDiagrammUrl ( ) ; break ; case Diagramm :: TYPE_DIAGRAMM : throw new \ InvalidArgumentException ( 'Unsupported diagramm type "' . $ type . '"' ) ; break ; case Diagramm :: TYPE_USE_CASE : $ uri = $ this -> getOptions ( ) -> getYumlUseCaseDiagrammUrl ( ) ; break ; default : throw new \ InvalidArgumentException ( 'Unkown diagramm type "' . $ type . '"' ) ; break ; } return $ uri ; } | Returns the URI for the yuml service for a diagramm type |
44,417 | public function requestDiagramm ( $ type , $ dslText ) { if ( $ this -> getOptions ( ) -> getReturnDummyImage ( ) ) { return $ this -> getOptions ( ) -> getDummyImage ( ) ; } $ httpClient = $ this -> getHttpClient ( ) ; $ httpClient -> setUri ( $ this -> getUriForDiagrammType ( $ type ) ) ; $ httpClient -> setParameterPost ( array ( 'dsl_text' => $ dslText ) ) ; $ response = $ httpClient -> send ( ) ; if ( ! $ response -> isSuccess ( ) ) { throw new \ UnexpectedValueException ( 'HTTP Request failed' ) ; } return $ this -> getOptions ( ) -> getYumlUrl ( ) . $ response -> getBody ( ) ; } | Requests a diagramm from yuml web service |
44,418 | public static function getConfig ( Loops $ loops = NULL , ArrayObject $ config = NULL ) { if ( ! $ loops ) { $ loops = Loops :: getCurrentLoops ( ) ; } if ( ! $ config ) { $ parts = explode ( "\\" , get_called_class ( ) ) ; if ( count ( $ parts ) > 2 && array_slice ( $ parts , 0 , 2 ) == [ "Loops" , "Service" ] ) { $ parts = array_slice ( $ parts , 2 ) ; } $ sectionname = Misc :: underscore ( implode ( "\\" , $ parts ) ) ; $ config = $ loops -> getService ( 'config' ) ; $ config = $ config -> offsetExists ( $ sectionname ) ? $ config -> offsetGet ( $ sectionname ) : new ArrayObject ; } $ result = static :: getDefaultConfig ( $ loops ) ; $ result -> merge ( $ config ) ; $ result -> offsetSet ( 'loops' , $ loops ) ; return $ result ; } | Returns the complete config of a service |
44,419 | public static function getService ( ArrayObject $ config , Loops $ loops ) { return Misc :: reflectionInstance ( static :: getClassname ( $ loops ) , static :: getConfig ( $ loops , $ config ) ) ; } | The factory method that creates the service instance |
44,420 | public static function hasService ( Loops $ loops ) { foreach ( static :: getDependencies ( $ loops ) as $ classname ) { if ( ! class_exists ( $ classname ) ) { return FALSE ; } } return TRUE ; } | Checks if all dependent classnames are defined |
44,421 | public function convert ( EventInterface $ event ) { $ connection = $ event -> getConnection ( ) ; $ array = array ( 'message' => $ event -> getMessage ( ) , 'params' => $ event -> getParams ( ) , 'command' => $ event -> getCommand ( ) , 'connection' => array ( 'serverHostname' => $ connection -> getServerHostname ( ) , 'serverPort' => $ connection -> getServerPort ( ) , 'nickname' => $ connection -> getNickname ( ) , 'username' => $ connection -> getUsername ( ) , 'hostname' => $ connection -> getHostname ( ) , 'servername' => $ connection -> getServername ( ) , 'realname' => $ connection -> getRealname ( ) , ) , ) ; if ( $ event instanceof UserEventInterface ) { $ array [ 'user' ] = array ( 'prefix' => $ event -> getPrefix ( ) , 'nick' => $ event -> getNick ( ) , 'username' => $ event -> getUsername ( ) , 'host' => $ event -> getHost ( ) , 'targets' => $ event -> getTargets ( ) , ) ; } if ( $ event instanceof CtcpEventInterface ) { $ array [ 'ctcp' ] = array ( 'command' => $ event -> getCtcpCommand ( ) , 'params' => $ event -> getCtcpParams ( ) , ) ; } return $ array ; } | Converts an event object into an array . |
44,422 | protected function attach ( $ stream ) { if ( is_resource ( $ stream ) === false ) { throw new InvalidArgumentException ( __METHOD__ . ' argument must be a valid PHP resource' ) ; } if ( is_resource ( $ this -> stream ) === true ) { $ this -> detach ( ) ; } $ this -> stream = $ stream ; } | Attach new resource to this object |
44,423 | public function close ( ) { if ( is_resource ( $ this -> stream ) === true ) { fclose ( $ this -> stream ) ; } $ this -> detach ( ) ; } | Closes the stream and any underlying resources |
44,424 | public function getSize ( ) { if ( is_resource ( $ this -> stream ) === true ) { $ stats = fstat ( $ this -> stream ) ; if ( isset ( $ stats [ 'size' ] ) ) { return $ stats [ 'size' ] ; } } return null ; } | Get the size of the stream if known |
44,425 | public function isWritable ( ) { if ( is_resource ( $ this -> stream ) === true ) { $ metadata = $ this -> getMetadata ( ) ; return Validator :: isWritable ( $ metadata ) ; } return false ; } | Returns whether or not the stream is writable |
44,426 | public function & AddFields ( $ fields ) { $ fields = func_get_args ( ) ; if ( count ( $ fields ) === 1 && is_array ( $ fields [ 0 ] ) ) $ fields = $ fields [ 0 ] ; foreach ( $ fields as & $ field ) $ this -> AddField ( $ field ) ; return $ this ; } | Add multiple fully configured form field instances function have infinite params with new field instances . |
44,427 | public function & AddField ( \ MvcCore \ Ext \ Forms \ IField $ field ) { if ( $ this -> dispatchState < 1 ) $ this -> Init ( ) ; $ fieldName = $ field -> GetName ( ) ; $ field -> SetForm ( $ this ) ; $ this -> fields [ $ fieldName ] = & $ field ; if ( $ field instanceof \ MvcCore \ Ext \ Forms \ Fields \ ISubmit ) { $ this -> submitFields [ $ fieldName ] = & $ field ; $ fieldCustomResultState = $ field -> GetCustomResultState ( ) ; if ( $ fieldCustomResultState !== NULL ) $ this -> customResultStates [ $ fieldName ] = $ fieldCustomResultState ; } return $ this ; } | Add fully configured form field instance . |
44,428 | public function HasField ( $ fieldOrFieldName = NULL ) { $ fieldName = NULL ; if ( $ fieldOrFieldName instanceof \ MvcCore \ Ext \ Forms \ IField ) { $ fieldName = $ fieldOrFieldName -> GetName ( ) ; } else if ( is_string ( $ fieldOrFieldName ) ) { $ fieldName = $ fieldOrFieldName ; } return isset ( $ this -> fields [ $ fieldName ] ) ; } | If TRUE if given field instance or given field name exists in form FALSE otherwise . |
44,429 | public function & RemoveField ( $ fieldOrFieldName = NULL ) { if ( $ this -> dispatchState < 1 ) $ this -> Init ( ) ; $ fieldName = NULL ; if ( $ fieldOrFieldName instanceof \ MvcCore \ Ext \ Forms \ IField ) { $ fieldName = $ fieldOrFieldName -> GetName ( ) ; } else if ( is_string ( $ fieldOrFieldName ) ) { $ fieldName = $ fieldOrFieldName ; } if ( isset ( $ this -> fields [ $ fieldName ] ) ) unset ( $ this -> fields [ $ fieldName ] ) ; return $ this ; } | Remove configured form field instance by given instance or given field name . If field is not found by it s name no error happened . |
44,430 | public function & GetField ( $ fieldName = '' ) { $ result = NULL ; if ( isset ( $ this -> fields [ $ fieldName ] ) ) $ result = & $ this -> fields [ $ fieldName ] ; return $ result ; } | Return form field instance by form field name if it exists else return null ; |
44,431 | public function & GetFirstFieldByType ( $ fieldType = '' ) { $ result = NULL ; foreach ( $ this -> fields as & $ field ) { if ( $ field -> GetType ( ) == $ fieldType ) { $ result = & $ field ; } } return $ result ; } | Return first caught form field instance by given field type string . If no field found NULL is returned . |
44,432 | public static function friendly ( $ time ) { $ now = time ( ) ; $ delta = abs ( $ time - $ now ) ; if ( $ delta < self :: MINUTE ) { return $ delta === self :: SECOND ? 'one second age' : [ '%num% second ago' , $ delta ] ; } if ( $ delta < 2 * self :: MINUTE ) { return 'a minute ago' ; } if ( $ delta < 45 * self :: MINUTE ) { return [ '%num% minutes ago' , ( int ) ( $ delta / self :: MINUTE ) ] ; } if ( $ delta < 90 * self :: MINUTE ) { return 'an hour ago' ; } if ( $ delta < 24 * self :: HOUR ) { return [ '%num% hours ago' , ( int ) ( $ delta / self :: HOUR ) ] ; } if ( $ delta < 48 * self :: HOUR ) { return 'yesterday' ; } if ( $ delta < self :: MONTH ) { return [ '%num% days ago' , ( int ) ( $ delta / self :: DAY ) ] ; } if ( $ delta < self :: YEAR ) { $ months = ( int ) ( $ delta / self :: MONTH ) ; return $ months <= 1 ? 'one month ago' : [ '%num% months ago' , $ months ] ; } $ years = ( int ) ( $ delta / self :: YEAR ) ; return $ years <= 1 ? 'one year ago' : [ '%num% years ago' , $ years ] ; } | get friendly time string |
44,433 | public function genDsn ( $ config ) : string { $ dsn = '' ; foreach ( $ config as $ key => $ value ) { if ( \ in_array ( $ key , self :: AVAILABLE_OPTIONS , false ) ) { $ dsn .= "$key=$value;" ; } } $ driver = strtolower ( $ config [ 'driver' ] ) ; return "$driver:$dsn" ; } | Generate DSN by parameters in config |
44,434 | private function buildStates ( ) : array { $ states = [ ] ; foreach ( $ this -> getOffsetFromArray ( $ this -> schema , 'states' , [ ] ) as $ state ) { $ states [ ] = new State ( $ this -> getOffsetFromArray ( $ state , 'name' ) , $ this -> buildEvents ( $ state ) , $ this -> getAdditionalFromArray ( $ state , [ 'events' , 'name' ] ) ) ; } return $ states ; } | Build states for process |
44,435 | private function buildEvents ( array $ state ) : array { $ events = [ ] ; foreach ( $ this -> getOffsetFromArray ( $ state , 'events' , [ ] ) as $ event ) { $ events [ ] = new Event ( $ this -> getOffsetFromArray ( $ event , 'name' ) , $ this -> getOffsetFromArray ( $ event , 'targetState' ) , $ this -> getOffsetFromArray ( $ event , 'errorState' ) , $ this -> getOffsetFromArray ( $ event , 'command' ) , $ this -> getAdditionalFromArray ( $ event , [ 'name' , 'command' , 'targetState' , 'errorState' ] ) ) ; } return $ events ; } | Build state events |
44,436 | public function getProcess ( ) : Process { if ( $ this -> process === null ) { $ this -> process = new Process ( $ this -> getSchemaName ( ) , $ this -> getInitialState ( ) , $ this -> buildStates ( ) ) ; } return $ this -> process ; } | Return schema process |
44,437 | public function load ( $ refresh = false , array $ options = array ( ) ) { if ( $ refresh || $ this -> _contents === null ) { $ this -> _contents = @ file_get_contents ( $ this -> _path ) ; if ( $ this -> _contents === false ) { throw LoadException :: create ( $ this -> _path ) ; } $ this -> setContents ( $ this -> decode ( $ options ) ) ; } return $ this ; } | Opens a file . |
44,438 | public function pushHandler ( HandlerInterface $ handler ) { array_unshift ( $ this -> handlers , $ handler ) ; if ( $ this -> _startTime === null ) { $ this -> _startTime = microtime ( true ) ; $ this -> _previousRecordTime = $ this -> _startTime ; } } | Pushes a handler on to the stack . |
44,439 | public function isHandling ( $ level ) { $ record = array ( 'message' => '' , 'context' => array ( ) , 'level' => $ level , 'level_name' => self :: getLevelName ( $ level ) , 'channel' => $ this -> name , 'datetime' => new \ DateTime ( ) , 'extra' => array ( ) , ) ; foreach ( $ this -> handlers as $ key => $ handler ) { if ( $ handler -> isHandling ( $ record ) ) { return true ; } } return false ; } | Checks whether the Logger has a handler that listens on the given level |
44,440 | protected function normalizeId ( $ id ) { if ( null !== $ this -> getSessionPrefix ( ) ) { return $ this -> getSessionPrefix ( ) . self :: ID_SEPARATOR . $ id ; } return $ id ; } | Method prepare id |
44,441 | private function computeSingleDocumentChangeSet ( $ document ) { $ state = $ this -> getDocumentState ( $ document ) ; if ( $ state !== self :: STATE_MANAGED && $ state !== self :: STATE_REMOVED ) { throw new \ InvalidArgumentException ( "Document has to be managed or scheduled for removal for single computation " . self :: objToStr ( $ document ) ) ; } $ class = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; if ( $ state === self :: STATE_MANAGED && $ class -> isChangeTrackingDeferredImplicit ( ) ) { $ this -> persist ( $ document ) ; } $ this -> computeScheduleInsertsChangeSets ( ) ; $ this -> computeScheduleUpsertsChangeSets ( ) ; if ( $ document instanceof Proxy && ! $ document -> __isInitialized__ ) { return ; } $ oid = spl_object_hash ( $ document ) ; if ( ! isset ( $ this -> documentInsertions [ $ oid ] ) && ! isset ( $ this -> documentUpserts [ $ oid ] ) && ! isset ( $ this -> documentDeletions [ $ oid ] ) && isset ( $ this -> documentStates [ $ oid ] ) ) { $ this -> computeChangeSet ( $ class , $ document ) ; } } | Only flush the given document according to a ruleset that keeps the UoW consistent . |
44,442 | private function executeExtraUpdates ( array $ options ) { foreach ( $ this -> extraUpdates as $ oid => $ update ) { list ( $ document , $ changeset ) = $ update ; $ this -> documentChangeSets [ $ oid ] = $ changeset ; $ this -> getDocumentPersister ( get_class ( $ document ) ) -> update ( $ document , $ options ) ; } } | Executes reference updates |
44,443 | public function getDocumentChangeSet ( $ document ) { $ oid = spl_object_hash ( $ document ) ; if ( isset ( $ this -> documentChangeSets [ $ oid ] ) ) { return $ this -> documentChangeSets [ $ oid ] ; } return array ( ) ; } | Gets the changeset for a document . |
44,444 | public function scheduleForUpdate ( $ document ) { $ oid = spl_object_hash ( $ document ) ; if ( ! isset ( $ this -> documentIdentifiers [ $ oid ] ) ) { throw new \ InvalidArgumentException ( "Document has no identity." ) ; } if ( isset ( $ this -> documentDeletions [ $ oid ] ) ) { throw new \ InvalidArgumentException ( "Document is removed." ) ; } if ( ! isset ( $ this -> documentUpdates [ $ oid ] ) && ! isset ( $ this -> documentInsertions [ $ oid ] ) && ! isset ( $ this -> documentUpserts [ $ oid ] ) ) { $ this -> documentUpdates [ $ oid ] = $ document ; } } | Schedules a document for being updated . |
44,445 | private function cascadePreRemove ( ClassMetadata $ class , $ document ) { $ hasPreRemoveListeners = $ this -> evm -> hasListeners ( Events :: preRemove ) ; foreach ( $ class -> fieldMappings as $ mapping ) { if ( isset ( $ mapping [ 'embedded' ] ) ) { $ value = $ class -> reflFields [ $ mapping [ 'fieldName' ] ] -> getValue ( $ document ) ; if ( $ value === null ) { continue ; } if ( $ mapping [ 'type' ] === 'one' ) { $ value = array ( $ value ) ; } foreach ( $ value as $ entry ) { $ entryClass = $ this -> dm -> getClassMetadata ( get_class ( $ entry ) ) ; if ( ! empty ( $ entryClass -> lifecycleCallbacks [ Events :: preRemove ] ) ) { $ entryClass -> invokeLifecycleCallbacks ( Events :: preRemove , $ entry ) ; } if ( $ hasPreRemoveListeners ) { $ this -> evm -> dispatchEvent ( Events :: preRemove , new LifecycleEventArgs ( $ entry , $ this -> dm ) ) ; } $ this -> cascadePreRemove ( $ entryClass , $ entry ) ; } } } } | Cascades the preRemove event to embedded documents . |
44,446 | private function cascadePreLoad ( ClassMetadata $ class , $ document , $ data ) { $ hasPreLoadListeners = $ this -> evm -> hasListeners ( Events :: preLoad ) ; foreach ( $ class -> fieldMappings as $ mapping ) { if ( isset ( $ mapping [ 'embedded' ] ) ) { $ value = $ class -> reflFields [ $ mapping [ 'fieldName' ] ] -> getValue ( $ document ) ; if ( $ value === null ) { continue ; } if ( $ mapping [ 'type' ] === 'one' ) { $ value = array ( $ value ) ; } foreach ( $ value as $ entry ) { $ entryClass = $ this -> dm -> getClassMetadata ( get_class ( $ entry ) ) ; if ( ! empty ( $ entryClass -> lifecycleCallbacks [ Events :: preLoad ] ) ) { $ args = array ( & $ data ) ; $ entryClass -> invokeLifecycleCallbacks ( Events :: preLoad , $ entry , $ args ) ; } if ( $ hasPreLoadListeners ) { $ this -> evm -> dispatchEvent ( Events :: preLoad , new PreLoadEventArgs ( $ entry , $ this -> dm , $ data [ $ mapping [ 'name' ] ] ) ) ; } $ this -> cascadePreLoad ( $ entryClass , $ entry , $ data [ $ mapping [ 'name' ] ] ) ; } } } } | Cascades the preLoad event to embedded documents . |
44,447 | public function getOriginalDocumentData ( $ document ) { $ oid = spl_object_hash ( $ document ) ; if ( isset ( $ this -> originalDocumentData [ $ oid ] ) ) { return $ this -> originalDocumentData [ $ oid ] ; } return array ( ) ; } | Gets the original data of a document . The original data is the data that was present at the time the document was reconstituted from the database . |
44,448 | public function setExitCode ( $ exitCode ) { $ this -> exitCode = ( int ) $ exitCode ; $ r = new \ ReflectionProperty ( $ this -> error , 'code' ) ; $ r -> setAccessible ( true ) ; $ r -> setValue ( $ this -> error , $ this -> exitCode ) ; } | Sets the exit code . |
44,449 | public function index ( PortfolioRequest $ request ) { $ view = $ this -> response -> theme -> listView ( ) ; if ( $ this -> response -> typeIs ( 'json' ) ) { $ function = camel_case ( 'get-' . $ view ) ; return $ this -> repository -> setPresenter ( \ Litecms \ Portfolio \ Repositories \ Presenter \ PortfolioPresenter :: class ) -> $ function ( ) ; } $ portfolios = $ this -> repository -> paginate ( ) ; return $ this -> response -> title ( trans ( 'portfolio::portfolio.names' ) ) -> view ( 'portfolio::portfolio.index' , true ) -> data ( compact ( 'portfolios' ) ) -> output ( ) ; } | Display a list of portfolio . |
44,450 | public function show ( PortfolioRequest $ request , Portfolio $ portfolio ) { if ( $ portfolio -> exists ) { $ view = 'portfolio::portfolio.show' ; } else { $ view = 'portfolio::portfolio.new' ; } return $ this -> response -> title ( trans ( 'app.view' ) . ' ' . trans ( 'portfolio::portfolio.name' ) ) -> data ( compact ( 'portfolio' ) ) -> view ( $ view , true ) -> output ( ) ; } | Display portfolio . |
44,451 | public function edit ( PortfolioRequest $ request , Portfolio $ portfolio ) { return $ this -> response -> title ( trans ( 'app.edit' ) . ' ' . trans ( 'portfolio::portfolio.name' ) ) -> view ( 'portfolio::portfolio.edit' , true ) -> data ( compact ( 'portfolio' ) ) -> output ( ) ; } | Show portfolio for editing . |
44,452 | public function update ( PortfolioRequest $ request , Portfolio $ portfolio ) { try { $ attributes = $ request -> all ( ) ; $ portfolio -> update ( $ attributes ) ; return $ this -> response -> message ( trans ( 'messages.success.updated' , [ 'Module' => trans ( 'portfolio::portfolio.name' ) ] ) ) -> code ( 204 ) -> status ( 'success' ) -> url ( guard_url ( 'portfolio/portfolio/' . $ portfolio -> getRouteKey ( ) ) ) -> redirect ( ) ; } catch ( Exception $ e ) { return $ this -> response -> message ( $ e -> getMessage ( ) ) -> code ( 400 ) -> status ( 'error' ) -> url ( guard_url ( 'portfolio/portfolio/' . $ portfolio -> getRouteKey ( ) ) ) -> redirect ( ) ; } } | Update the portfolio . |
44,453 | public function destroy ( PortfolioRequest $ request , Portfolio $ portfolio ) { try { $ portfolio -> delete ( ) ; return $ this -> response -> message ( trans ( 'messages.success.deleted' , [ 'Module' => trans ( 'portfolio::portfolio.name' ) ] ) ) -> code ( 202 ) -> status ( 'success' ) -> url ( guard_url ( 'portfolio/portfolio/0' ) ) -> redirect ( ) ; } catch ( Exception $ e ) { return $ this -> response -> message ( $ e -> getMessage ( ) ) -> code ( 400 ) -> status ( 'error' ) -> url ( guard_url ( 'portfolio/portfolio/' . $ portfolio -> getRouteKey ( ) ) ) -> redirect ( ) ; } } | Remove the portfolio . |
44,454 | public function connect ( ) { $ dsnString = "{$this->dbDriver}:host={$this->dbHostname};dbname={$this->dbName};" ; $ dsnString .= "charset={$this->dbCharset}" ; try { $ this -> dbConnection = new \ PDO ( $ dsnString , "{$this->dbUsername}" , "{$this->dbPassword}" , $ this -> driverOptions ) ; } catch ( \ PDOException $ ex ) { throw new \ InvalidArgumentException ( __METHOD__ . ': ' . $ ex -> getMessage ( ) ) ; } return $ this -> dbConnection ; } | Connect to a database by using constructor params |
44,455 | public function query ( $ queryString , array $ queryValues = [ ] ) { if ( ! is_string ( $ queryString ) || empty ( $ queryString ) ) { throw new \ InvalidArgumentException ( __METHOD__ . ': The specified query is not valid.' ) ; } $ this -> connect ( ) ; $ this -> resourceHandle = $ this -> dbConnection -> prepare ( $ queryString ) ; try { $ this -> dbConnection -> beginTransaction ( ) ; $ this -> executionStatus = $ this -> resourceHandle -> execute ( $ queryValues ? : null ) ; $ this -> lastInsertedId = $ this -> dbConnection -> lastInsertId ( ) ; $ this -> dbConnection -> commit ( ) ; } catch ( \ PDOException $ ex ) { $ this -> dbConnection -> rollBack ( ) ; $ this -> executionStatus = false ; $ this -> resourceHandle -> closeCursor ( ) ; throw new \ RuntimeException ( __METHOD__ . ": {$ex->getMessage()}\nqueryString: {$queryString}" ) ; } return $ this -> resourceHandle ; } | Execute a query or a prepared statement with a params array values . |
44,456 | public function select ( $ table , $ conditions = null , $ fields = null , $ order = null , $ limit = null , $ offset = null ) { if ( is_null ( $ fields ) ) { $ fields = "*" ; } $ queryString = "SELECT {$fields} FROM {$table} " ; if ( ! is_null ( $ conditions ) ) { $ queryString .= "WHERE {$conditions} " ; } if ( ! is_null ( $ order ) ) { $ queryString .= "ORDER BY {$order} " ; } if ( ! is_null ( $ limit ) ) { $ queryString .= "LIMIT {$limit} " ; } if ( ! is_null ( $ offset ) && ! is_null ( $ limit ) ) { $ queryString .= "OFFSET {$offset} " ; } $ queryString .= ";" ; $ this -> query ( $ queryString ) ; return $ this -> countRows ( ) ; } | Perform a SELECT statement |
44,457 | public function insert ( $ table , array $ data ) { $ nameFields = join ( ',' , array_keys ( $ data ) ) ; $ preparedValues = $ this -> prepareValues ( $ data ) ; $ keyValues = join ( "," , array_keys ( $ preparedValues ) ) ; $ queryString = "INSERT INTO {$table} ({$nameFields}) VALUES ({$keyValues});" ; $ this -> query ( $ queryString , $ preparedValues ) ; return $ this -> getInsertId ( ) ; } | Perform a INSERT statement |
44,458 | private function prepareValues ( $ arrayData ) { $ arrayData = array_values ( $ arrayData ) ; $ preparedValues = [ ] ; $ vNumber = 1 ; foreach ( $ arrayData as $ value ) { $ preparedValues [ ":value{$vNumber}" ] = "$value" ; $ vNumber ++ ; } unset ( $ arrayData ) ; unset ( $ vNumber ) ; return $ preparedValues ; } | Preparate values for execute |
44,459 | public function update ( $ table , array $ data , $ conditions ) { $ nameFields = array_keys ( $ data ) ; $ preparedValues = $ this -> prepareValues ( $ data ) ; $ queryString = "UPDATE {$table} SET " ; $ fNumber = 0 ; foreach ( $ preparedValues as $ key => $ value ) { unset ( $ value ) ; $ queryString .= "{$nameFields[$fNumber]} = {$key}, " ; $ fNumber ++ ; } $ queryString = preg_replace ( '/,\ $/' , ' ' , $ queryString ) ; $ queryString .= "WHERE {$conditions};" ; $ this -> query ( $ queryString , $ preparedValues ) ; return $ this -> getAffectedRows ( ) ; } | Perform a UPDATE statement |
44,460 | private function specialChar ( $ char ) { switch ( $ char ) { case "!" : return $ this -> hexToChar ( '00A1' ) ; case "_" : return $ this -> hexToChar ( '203E' ) ; case "&" : return $ this -> hexToChar ( '214B' ) ; case "?" : return $ this -> hexToChar ( '00BF' ) ; case "." : return $ this -> hexToChar ( 'U2D9' ) ; case "\"" : return $ this -> hexToChar ( '201E' ) ; case "'" : return $ this -> hexToChar ( '002C' ) ; case "(" : return $ this -> hexToChar ( '0029' ) ; case ")" : return $ this -> hexToChar ( '0028' ) ; default : return $ char ; } } | Switch statement to flip the special and punctuation characters |
44,461 | protected function _createInvocationException ( $ message = null , $ code = null , RootException $ previous = null , callable $ callable = null , $ args = null ) { return new InvocationException ( $ message , $ code , $ previous , $ callable , $ args ) ; } | Creates a new Invocation exception . |
44,462 | public static function create ( string $ locale = 'en' ) : ValidatorFactory { $ translator = new Translator ; $ factory = new ValidatorFactory ( $ translator ) ; $ factory = $ factory -> withBuiltInFactories ( ) ; $ factory = $ factory -> withBuiltInTemplates ( $ locale ) ; return $ factory ; } | Return a validator factory using all the default rule factories and the templates of the given locale . |
44,463 | private function withBuiltInFactories ( ) : ValidatorFactory { $ keys = array_keys ( self :: $ defaults ) ; return array_reduce ( $ keys , function ( $ factory , $ key ) { $ rule = self :: $ defaults [ $ key ] ; return $ factory -> withRuleFactory ( $ key , function ( array $ parameters = [ ] ) use ( $ rule ) { return new $ rule ( ... $ parameters ) ; } ) ; } , $ this ) ; } | Return a new validator factory with a rule factory for each default rules . |
44,464 | private function withBuiltInTemplates ( string $ locale ) : ValidatorFactory { $ templates = include ( __DIR__ . '/../lang/' . $ locale . '.php' ) ; return $ this -> withDefaultTemplates ( $ templates ) ; } | Return a new validator factory using the built in templates for the given locale . |
44,465 | public function getValidator ( array $ rules = [ ] ) : Validator { $ parser = new RulesParser ( $ this -> factories ) ; return new Validator ( $ rules , $ parser , $ this -> translator ) ; } | Return a validator using the given rules . |
44,466 | public function withRuleFactory ( string $ name , callable $ factory ) : ValidatorFactory { $ factories = array_merge ( $ this -> factories , [ $ name => $ factory ] ) ; return new ValidatorFactory ( $ this -> translator , $ factories ) ; } | Return a new validator factory with an additional rule factory . |
44,467 | public function withDefaultLabels ( array $ labels ) : ValidatorFactory { $ translator = $ this -> translator -> withLabels ( $ labels ) ; return new ValidatorFactory ( $ translator , $ this -> factories ) ; } | Return a new validator factory with an additional list of labels added to the translator . |
44,468 | public function withDefaultTemplates ( array $ templates ) : ValidatorFactory { $ translator = $ this -> translator -> withTemplates ( $ templates ) ; return new ValidatorFactory ( $ translator , $ this -> factories ) ; } | Return a new validator factory with an additional list of templates added to the translator . |
44,469 | public static function clear ( ) { $ isClearAll = true ; if ( $ _COOKIE ) { foreach ( $ _COOKIE as $ key => $ value ) { $ result = self :: delete ( $ key ) ; if ( ! $ result ) { $ isClearAll = false ; } } } return $ isClearAll ; } | Clear all cookies |
44,470 | public function disableAction ( $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'CoreExtraBundle:Actor' ) -> find ( $ id ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Actor entity.' ) ; } $ user = $ this -> get ( 'security.token_storage' ) -> getToken ( ) -> getUser ( ) ; if ( ! $ user -> isGranted ( 'ROLE_ADMIN' ) ) { return $ this -> redirect ( $ this -> generateUrl ( 'coreextra_newsletter_index' ) ) ; } $ entity -> setNewsletter ( false ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'newsletter.subscripts.disable' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'coreextra_newsletter_subscription' ) ) ; } | Edits an existing Subscriptors entity . |
44,471 | public function showAction ( Newsletter $ newsletter ) { $ deleteForm = $ this -> createDeleteForm ( $ newsletter ) ; return array ( 'entity' => $ newsletter , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Finds and displays a Newsletter entity . |
44,472 | public function newShippingAction ( Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = new NewsletterShipping ( ) ; $ data = $ request -> request -> get ( 'corebundle_newslettershippingtype' ) ; $ formConfig = array ( ) ; if ( isset ( $ data [ 'type' ] ) && $ data [ 'type' ] == 'token' ) { $ formConfig [ 'token' ] = true ; } $ form = $ this -> createForm ( 'CoreExtraBundle\Form\NewsletterShippingType' , $ entity , $ formConfig ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ emailArray = $ this -> get ( 'core_manager' ) -> getSubscriptorFromType ( $ entity ) ; $ entity -> setTotalSent ( count ( $ emailArray ) ) ; if ( $ entity -> getType ( ) == NewsletterShipping :: TYPE_TOKEN ) { $ em = $ this -> getDoctrine ( ) -> getEntityManager ( ) ; $ connection = $ em -> getConnection ( ) ; $ statement = $ connection -> prepare ( "TRUNCATE TABLE email_token" ) ; $ statement -> execute ( ) ; foreach ( $ emailArray as $ email ) { $ emailToken = new EmailToken ( ) ; $ emailToken -> setEmail ( $ email ) ; $ token = sha1 ( uniqid ( ) ) ; $ emailToken -> setToken ( $ token ) ; $ em -> persist ( $ emailToken ) ; $ body = preg_replace ( '/(#TOKEN#)/' , $ token , $ entity -> getNewsletter ( ) -> getBody ( ) ) ; $ this -> get ( 'core.mailer' ) -> sendShipping ( array ( $ email ) , NewsletterShipping :: TYPE_TOKEN , $ body ) ; } } else { $ body = $ entity -> getNewsletter ( ) -> getBody ( ) ; $ this -> get ( 'core.mailer' ) -> sendShipping ( $ emailArray , $ entity -> getType ( ) , $ body ) ; } $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; if ( $ request -> isXMLHttpRequest ( ) ) { return new JsonResponse ( array ( 'id' => $ entity -> getId ( ) ) ) ; } $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'newsletter.shipping.created' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'coreextra_newsletter_showshipping' , array ( 'id' => $ entity -> getId ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; } | Creates a new Shipping entity . |
44,473 | public function showShippingAction ( NewsletterShipping $ newsletterShipping ) { $ deleteForm = $ this -> createNShippingDeleteForm ( $ newsletterShipping ) ; return array ( 'entity' => $ newsletterShipping , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Finds and displays a NewsletterShipping entity . |
44,474 | public function deleteShippingAction ( Request $ request , NewsletterShipping $ newsletterShipping ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> remove ( $ newsletterShipping ) ; $ em -> flush ( ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'newsletter.shipping.deleted' ) ; if ( $ request -> query -> get ( 'redirect' ) != '' ) { return $ this -> redirect ( $ request -> query -> get ( 'redirect' ) ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'coreextra_newsletter_shipping' ) ) ; } | Deletes a NewsletterShipping entity . |
44,475 | public function ask ( $ question , $ default = null ) { $ que = new Question ( $ question , $ default ) ; $ helper = new SymfonyQuestionHelper ( ) ; return $ helper -> ask ( $ this -> input , $ this -> output , $ que ) ; } | Ask string param from stdin php input |
44,476 | public function optionOrAsk ( $ option , $ question , $ default = null ) { $ value = $ this -> input -> getOption ( $ option ) ; if ( $ value === null || Str :: likeEmpty ( $ value ) ) { $ value = $ this -> ask ( $ question , $ default ) ; } return $ value ; } | Get input option value or ask it if empty |
44,477 | public static function post ( $ url , $ payload , $ contentType = 'Content-Type: application/json' ) { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , "POST" ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ payload ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( $ contentType , 'Content-Length: ' . strlen ( $ payload ) ) ) ; $ result = curl_exec ( $ ch ) ; return $ result ; } | Function to post a payload to a url using cURL . |
44,478 | public static function createField ( $ title , $ value , $ short = true ) { $ field = new SlackResultAttachmentField ( ) ; $ field -> setTitle ( $ title ) ; $ field -> setValue ( $ value ) ; $ field -> setShort ( $ short ) ; return $ field ; } | Returns a \ SlackHookFramework \ SlackResultAttachmentField instance with the given values . |
44,479 | private function initContainer ( ) { $ dicons = ( array ) $ this -> app -> config ( 'container.dicon' ) ; $ container = ContainerFactory :: create ( ) ; foreach ( $ dicons as $ dicon ) { $ file = $ this -> app -> getLoader ( ) -> find ( $ dicon ) -> first ( ) ; $ container -> import ( $ file ) ; } $ container -> register ( 'framework' , $ this ) ; $ container -> register ( 'application' , $ this -> app ) ; $ container -> register ( 'loader' , $ this -> app -> getLoader ( ) ) ; $ this -> setContainer ( $ container ) ; $ this -> app -> setContainer ( $ container ) ; foreach ( ( array ) $ this -> app -> config ( 'container.callback.initialized' ) as $ callback ) { $ callback ( $ container ) ; } } | initialize container . |
44,480 | public function setReference ( ChildReference $ v = null ) { if ( $ v === null ) { $ this -> setReferenceId ( NULL ) ; } else { $ this -> setReferenceId ( $ v -> getId ( ) ) ; } $ this -> aReference = $ v ; if ( $ v !== null ) { $ v -> addVideo ( $ this ) ; } return $ this ; } | Declares an association between this object and a ChildReference object . |
44,481 | public function getReference ( ConnectionInterface $ con = null ) { if ( $ this -> aReference === null && ( $ this -> reference_id !== null ) ) { $ this -> aReference = ChildReferenceQuery :: create ( ) -> findPk ( $ this -> reference_id , $ con ) ; } return $ this -> aReference ; } | Get the associated ChildReference object |
44,482 | public function initFeaturedTutorialSkills ( $ overrideExisting = true ) { if ( null !== $ this -> collFeaturedTutorialSkills && ! $ overrideExisting ) { return ; } $ this -> collFeaturedTutorialSkills = new ObjectCollection ( ) ; $ this -> collFeaturedTutorialSkills -> setModel ( '\gossi\trixionary\model\Skill' ) ; } | Initializes the collFeaturedTutorialSkills collection . |
44,483 | public function getFeaturedTutorialSkillsJoinSport ( Criteria $ criteria = null , ConnectionInterface $ con = null , $ joinBehavior = Criteria :: LEFT_JOIN ) { $ query = ChildSkillQuery :: create ( null , $ criteria ) ; $ query -> joinWith ( 'Sport' , $ joinBehavior ) ; return $ this -> getFeaturedTutorialSkills ( $ query , $ con ) ; } | If this collection has already been initialized with an identical criteria it returns the collection . Otherwise if this Video is new it will return an empty collection ; or if this Video has previously been saved it will retrieve related FeaturedTutorialSkills from storage . |
44,484 | public function createURL ( ) { $ url = "https://secure.gravatar.com/avatar/" . $ this -> createHash ( ) ; $ url = $ url . "?s=" . $ this -> size . "&d=" . $ this -> default . "&r=" . $ this -> rating ; if ( $ this -> forceDefault == true ) { $ url = $ url . '&f=y' ; } return $ url ; } | Creates URL of a gravatar image . |
44,485 | public function css ( $ cssClasses ) { if ( ! $ cssClasses ) { return $ this ; } $ cssClasses = explode ( ' ' , $ cssClasses ) ; foreach ( $ cssClasses as $ cssClass ) { if ( $ cssClass && false === in_array ( $ cssClass , $ this -> cssClasses ) ) { $ this -> cssClasses [ ] = $ cssClass ; } } return $ this ; } | Add a CSS class to the element . Multiple classes can be passed as a space - separated string . |
44,486 | public function ghost ( $ ghostValue ) { if ( $ this -> isCheckbox ( ) ) { $ this -> ghostCheckboxValue = $ ghostValue ; $ this -> avoidGhost = ( null === $ ghostValue ) ; } return $ this ; } | Set the ghost value for the checkbox . |
44,487 | protected function getGhost ( ) { if ( null !== $ this -> ghostCheckboxValue ) { return $ this -> ghostCheckboxValue ; } if ( ! $ this -> avoidGhost ) { return config ( 'blade-materialize.checkbox_ghost' ) ; } return null ; } | Return the checkbox ghost value or null if there is no ghost value ; |
44,488 | public function createSchema ( ) { $ query = 'CREATE TABLE IF NOT EXISTS `' . self :: LIST_COLLECTION_TABLE_NAME . '` ( `id` int NOT NULL AUTO_INCREMENT, `uuid` varchar(255) UNIQUE NOT NULL, `headers` text DEFAULT NULL, `created_at` TIMESTAMP NOT NULL, `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;' ; $ this -> pdo -> exec ( $ query ) ; $ query2 = 'CREATE TABLE IF NOT EXISTS `' . self :: LIST_ELEMENT_TABLE_NAME . '` ( `id` int NOT NULL AUTO_INCREMENT, `uuid` varchar(255) NOT NULL, `list` varchar(255) NOT NULL, `body` text DEFAULT NULL, `created_at` TIMESTAMP NOT NULL, `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), PRIMARY KEY (`id`), CONSTRAINT `list_foreign_key` FOREIGN KEY (`list`) REFERENCES `' . self :: LIST_COLLECTION_TABLE_NAME . '`(`uuid`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;' ; $ this -> pdo -> exec ( $ query2 ) ; } | creates database schema . |
44,489 | public function get ( ) { $ exec = $ this -> getExecutor ( ) ; $ exec -> setCommand ( 'hostname' ) ; $ exec -> run ( ) ; $ output = $ exec -> getOutput ( ) ; return $ output [ 'stdout' ] ; } | returns the current hostname |
44,490 | public function set ( $ name ) { $ exec = $ this -> getExecutor ( ) ; $ exec -> setCommand ( 'hostname ' . $ name ) ; $ exec -> run ( ) ; return $ exec -> hasErrors ( ) ; } | sets the hostname |
44,491 | protected function publishFiles ( Filesystem $ filesystem , array $ paths , $ force = false ) { foreach ( $ paths as $ from => $ to ) { if ( $ filesystem -> isFile ( $ from ) ) { $ this -> publishFile ( $ filesystem , $ from , $ to , $ force ) ; } elseif ( $ filesystem -> isDirectory ( $ from ) ) { $ this -> publishDirectory ( $ from , $ to , $ force ) ; } else { $ this -> error ( "Can't locate path: <{$from}>" ) ; } } } | Publish files . |
44,492 | public function paths ( ) : void { $ paths = $ this -> getConfigPaths ( ) ; WP_CLI :: success ( count ( $ paths ) . ' config files found.' ) ; WP_CLI :: success ( 'The later ones override any previous configurations.' ) ; foreach ( $ paths as $ path ) { WP_CLI :: log ( $ path ) ; } } | Gets the paths to all config files . |
44,493 | public function cat ( ) : void { $ paths = $ this -> getConfigPaths ( ) ; foreach ( $ paths as $ path ) { WP_CLI :: line ( WP_CLI :: colorize ( "%B====> Printing $path%n" ) ) ; $ contents = file_get_contents ( $ path ) ; $ contentsWithoutLineBreaks = str_replace ( [ "\r" , "\n" ] , '' , $ contents ) ; if ( empty ( $ contentsWithoutLineBreaks ) ) { WP_CLI :: error_multi_line ( [ "File '$path' is empty." , ] ) ; } WP_CLI :: line ( $ contents ) ; WP_CLI :: line ( '' ) ; } } | Prints the content of all config files . |
44,494 | public function validate ( ) : void { $ paths = $ this -> getConfigPaths ( ) ; foreach ( $ paths as $ path ) { WP_CLI :: line ( WP_CLI :: colorize ( "%B====> Validating $path%n" ) ) ; try { Toml :: parseFile ( $ path ) ; WP_CLI :: success ( "File '$path' is valid." ) ; } catch ( ParseException $ parseException ) { WP_CLI :: error_multi_line ( [ $ parseException -> getMessage ( ) , ] ) ; WP_CLI :: warning ( "File '$path' will be ignored." ) ; } WP_CLI :: line ( '' ) ; } } | Validates the TOML syntax of all config files . |
44,495 | public function _ ( $ translateKey , $ defaultTranslation = "" , $ placeholders = null ) { $ translation = $ translateKey ; if ( is_array ( $ defaultTranslation ) && $ placeholders === null ) { $ placeholders = $ defaultTranslation ; } else { if ( $ defaultTranslation != "" ) { $ translation = $ defaultTranslation ; } } if ( $ this -> exists ( $ translateKey ) ) { $ translation = $ this -> _translate [ $ translateKey ] ; } return $ this -> replacePlaceholders ( $ translation , $ placeholders ) ; } | Returns the translation related to the given key |
44,496 | public function setTranslation ( $ translation ) { if ( is_array ( $ translation ) ) { $ this -> _translate = array_merge ( $ this -> _translate , $ translation ) ; } } | Set translation data |
44,497 | public function distributeExpire ( EventInterface $ event ) { $ dist = $ this -> distribution ; $ item = $ event -> getParam ( 'item' ) ; if ( $ item instanceof CacheItemExtendedInterface ) { $ ttl = $ item -> getExpiration ( ) -> getTimestamp ( ) - time ( ) ; $ percent = ( rand ( 0 , $ dist * 2 ) - $ dist ) * 0.001 ; $ new_ttl = ( int ) round ( $ ttl + $ ttl * $ percent ) ; $ item -> expiresAfter ( $ new_ttl ) ; } return true ; } | Evenly distribute the expiration time |
44,498 | public function count ( ) : int { if ( $ this -> count == null ) { $ this -> count = 0 ; if ( $ handle = opendir ( $ this -> fileInfo -> getAbsoluteFilePath ( ) ) ) { while ( ( $ file = readdir ( $ handle ) ) !== false ) { if ( ! in_array ( $ file , array ( '.' , '..' ) ) ) { $ this -> count ++ ; } } closedir ( $ handle ) ; } } return $ this -> count ; } | Returns the total number of directories and files in the directory . |
44,499 | public static function forInstallerNameAndPackageName ( $ installerName , $ packageName , Exception $ cause = null ) { return new static ( sprintf ( 'The installer "%s" does not exist in package "%s".' , $ installerName , $ packageName ) , 0 , $ cause ) ; } | Creates an exception for an installer name that was not found in a given package . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.