idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
45,200 | public function setParsed ( bool $ parsed = true ) : Result { $ this -> parsed = ( boolean ) $ parsed ; return $ this ; } | Mark the output as parsed |
45,201 | public static function forge ( $ uri = null , $ options = true , $ method = null ) { is_bool ( $ options ) and $ options = array ( 'route' => $ options ) ; is_string ( $ options ) and $ options = array ( 'driver' => $ options ) ; if ( ! empty ( $ options [ 'driver' ] ) ) { $ class = \ Inflector :: words_to_upper ( 'Request_' . $ options [ 'driver' ] ) ; return $ class :: forge ( $ uri , $ options , $ method ) ; } $ request = new static ( $ uri , isset ( $ options [ 'route' ] ) ? $ options [ 'route' ] : true , $ method ) ; if ( static :: $ active ) { $ request -> parent = static :: $ active ; static :: $ active -> children [ ] = $ request ; } \ Event :: instance ( ) -> has_events ( 'request_created' ) and \ Event :: instance ( ) -> trigger ( 'request_created' , '' , 'none' ) ; return $ request ; } | Generates a new request . The request is then set to be the active request . If this is the first request then save that as the main request for the app . |
45,202 | public static function reset_request ( $ full = false ) { static :: $ active and static :: $ active = static :: $ active -> parent ( ) ; if ( $ full ) { static :: $ main = null ; } } | Reset s the active request with the previous one . This is needed after the active request is finished . |
45,203 | public function param ( $ param , $ default = null ) { if ( ! isset ( $ this -> named_params [ $ param ] ) ) { return \ Fuel :: value ( $ default ) ; } return $ this -> named_params [ $ param ] ; } | Gets a specific named parameter |
45,204 | public function getClasses ( ) { $ classes = [ ] ; $ sizes = $ this -> sizes ; if ( isset ( $ sizes [ 'phone' ] ) ) { $ classes [ ] = 'col-xs-' . $ sizes [ 'phone' ] ; } if ( isset ( $ sizes [ 'tablet' ] ) ) { $ classes [ ] = 'col-sm-' . $ sizes [ 'tablet' ] ; } if ( isset ( $ sizes [ 'mediumDesktop' ] ) ) { $ classes [ ] = 'col-md-' . $ sizes [ 'mediumDesktop' ] ; } if ( isset ( $ sizes [ 'largeDesktop' ] ) ) { $ classes [ ] = 'col-lg-' . $ sizes [ 'largeDesktop' ] ; } return implode ( ' ' , $ classes ) ; } | Get classes . |
45,205 | public function getSizes ( ) { $ sizes = [ ] ; if ( $ this -> phoneSize === 'auto' ) { $ sizes [ 'phone' ] = $ this -> generatePhoneSize ( ) ; } elseif ( $ this -> phoneSize === true && $ this -> hasPhoneColumns ) { $ sizes [ 'phone' ] = $ this -> phoneColumns ; } if ( $ this -> tabletSize === 'auto' ) { $ sizes [ 'tablet' ] = $ this -> generateTabletSize ( ) ; } elseif ( $ this -> tabletSize === true && $ this -> hasTabletColumns ) { $ sizes [ 'tablet' ] = $ this -> tabletColumns ; } if ( $ this -> mediumDesktopSize === 'auto' ) { $ sizes [ 'mediumDesktop' ] = $ this -> generateMediumDesktopSize ( ) ; } elseif ( $ this -> mediumDesktopSize === true && $ this -> hasMediumDesktopColumns ) { $ sizes [ 'mediumDesktop' ] = $ this -> mediumDesktopColumns ; } if ( $ this -> largeDesktopSize === 'auto' ) { $ sizes [ 'largeDesktop' ] = $ this -> generateLargeDesktopSize ( ) ; } elseif ( $ this -> largeDesktopSize === true && $ this -> hasLargeDesktopColumns ) { $ sizes [ 'largeDesktop' ] = $ this -> largeDesktopColumns ; } return $ sizes ; } | Get sizes . |
45,206 | public function getMaxColumns ( $ size = null ) { if ( is_object ( $ this -> content ) && property_exists ( $ this -> content , 'maxColumns' ) && ! is_null ( $ this -> content -> maxColumns ) ) { return $ this -> content -> maxColumns ; } if ( is_null ( $ size ) ) { $ size = $ this -> baseSize ; } $ columnAttribute = 'max' . ucfirst ( $ size ) . 'Columns' ; return $ this -> { $ columnAttribute } ; } | Get max columns . |
45,207 | public function setMaxColumns ( $ columns , $ size = null ) { if ( is_null ( $ size ) ) { $ size = $ this -> baseSize ; } $ columnAttribute = 'max' . ucfirst ( $ size ) . 'Columns' ; $ this -> { $ columnAttribute } = $ columns ; } | Set max columns . |
45,208 | public function getFlex ( $ size = null ) { if ( is_null ( $ size ) ) { $ size = $ this -> baseSize ; } $ getter = $ size . 'Columns' ; $ flex = $ this -> getMaxColumns ( $ size ) - $ this -> { $ getter } ; if ( $ flex < 0 ) { return 0 ; } return $ flex ; } | Get flex . |
45,209 | public static function open ( $ tag , array $ options = [ ] , $ self = false ) { $ attributes = self :: attributes ( $ options ) ; if ( ! $ self || is_null ( $ self ) ) { self :: $ opened [ ] = $ tag ; return '<' . $ tag . $ attributes . '>' ; } else { return '<' . $ tag . $ attributes . ' />' ; } } | open html tag . |
45,210 | public static function close ( ) { $ tag = self :: $ opened [ count ( self :: $ opened ) - 1 ] ; array_pop ( self :: $ opened ) ; return '</' . $ tag . '>' ; } | close the last open html tag . |
45,211 | public static function title ( $ title = null ) { if ( is_null ( $ title ) ) { $ title = config ( 'app.title' ) ; } $ tag = static :: open ( 'title' ) ; $ tag .= $ title ; $ tag .= static :: close ( ) ; return $ tag ; } | The HTML title tag . |
45,212 | private function _prepareColumns ( array $ columnArray ) { if ( count ( $ columnArray ) === 0 ) { throw new \ Exception ( 'The column method of the statement must called before!' ) ; } foreach ( $ columnArray as $ column ) { $ this -> columns .= $ column -> getColumnName ( ) . ', ' ; } $ this -> columns = rtrim ( $ this -> columns ) ; $ this -> columns = rtrim ( $ this -> columns , ',' ) ; return $ this ; } | Validate and prepare the columns property to set it to the query . |
45,213 | private function _prepareValues ( array $ valueArrays ) { if ( count ( $ valueArrays ) === 0 ) { throw new \ Exception ( 'The value method of the statement must called before!' ) ; } foreach ( $ valueArrays as $ valueArray ) { $ valueString = '(' ; foreach ( $ valueArray as $ value ) { $ valueString .= $ value -> getValue ( ) . ', ' ; } $ valueString = rtrim ( $ valueString ) ; $ valueString = rtrim ( $ valueString , ',' ) . ')' ; $ this -> values .= $ valueString . ', ' ; } $ this -> values = rtrim ( $ this -> values ) ; $ this -> values = rtrim ( $ this -> values , ',' ) ; return $ this ; } | Validate and prepare the values property to set it to the query . |
45,214 | public static function importRoutes ( Event $ event ) { $ options = self :: getOptions ( $ event ) ; $ appDir = $ options [ 'symfony-app-dir' ] ; $ webDir = $ options [ 'symfony-web-dir' ] ; if ( ! is_dir ( $ webDir ) ) { echo 'The symfony-web-dir (' . $ webDir . ') specified in composer.json was not found in ' . getcwd ( ) . ', can not install assets.' . PHP_EOL ; return ; } static :: executeCommand ( $ event , $ appDir , 'wucdbm_menu_builder:import_routes' ) ; } | Imports routes into the database . |
45,215 | public function AvailableApplications ( ) { if ( ! is_array ( $ this -> _AvailableApplications ) ) { $ ApplicationInfo = array ( ) ; $ AppFolders = Gdn_FileSystem :: Folders ( PATH_APPLICATIONS ) ; $ ApplicationAboutFiles = Gdn_FileSystem :: FindAll ( PATH_APPLICATIONS , 'settings' . DS . 'about.php' , $ AppFolders ) ; $ ApplicationCount = count ( $ ApplicationAboutFiles ) ; for ( $ i = 0 ; $ i < $ ApplicationCount ; ++ $ i ) { include ( $ ApplicationAboutFiles [ $ i ] ) ; foreach ( $ ApplicationInfo as $ ApplicationName => $ Info ) { if ( array_key_exists ( 'Folder' , $ ApplicationInfo [ $ ApplicationName ] ) === FALSE ) { $ Folder = substr ( $ ApplicationAboutFiles [ $ i ] , strlen ( PATH_APPLICATIONS ) ) ; if ( substr ( $ Folder , 0 , 1 ) == DS ) $ Folder = substr ( $ Folder , 1 ) ; $ Folder = substr ( $ Folder , 0 , strpos ( $ Folder , DS ) ) ; $ ApplicationInfo [ $ ApplicationName ] [ 'Folder' ] = $ Folder ; } } } foreach ( $ ApplicationInfo as $ Index => & $ Info ) { $ Info [ 'Index' ] = $ Index ; } $ this -> _AvailableApplications = $ ApplicationInfo ; } return $ this -> _AvailableApplications ; } | Looks through the root Garden directory for valid applications and returns them as an associative array of Application Name = > Application Info Array . It also adds a Folder definition to the Application Info Array for each application . |
45,216 | public function EnabledApplications ( ) { if ( ! is_array ( $ this -> _EnabledApplications ) ) { $ EnabledApplications = Gdn :: Config ( 'EnabledApplications' , array ( 'Dashboard' => 'dashboard' ) ) ; foreach ( $ EnabledApplications as $ Name => $ Folder ) { $ EnabledApplications [ $ Name ] = array ( 'Folder' => $ Folder ) ; $ EnabledApplications [ $ Name ] [ 'Version' ] = '' ; $ EnabledApplications [ $ Name ] [ 'Index' ] = $ Name ; $ AboutPath = PATH_APPLICATIONS . '/' . strtolower ( $ Name ) . '/settings/about.php' ; if ( file_exists ( $ AboutPath ) ) { $ ApplicationInfo = array ( ) ; include $ AboutPath ; $ EnabledApplications [ $ Name ] [ 'Version' ] = GetValueR ( "$Name.Version" , $ ApplicationInfo , '' ) ; } } $ this -> _EnabledApplications = $ EnabledApplications ; } return $ this -> _EnabledApplications ; } | Gets an array of all of the enabled applications . |
45,217 | private function prepareService ( ) { if ( ! ( $ bound = $ this -> app -> bound ( ServiceShortCuts :: CORE_INITIALIZED ) ) ) { $ this -> services ( [ 'LaravelCommode\Common\CommodeCommonServiceProvider' ] ) ; } $ withGhostServiceDo = function ( GhostServices $ appServices ) use ( $ bound ) { if ( ! $ bound ) { $ appServices -> register ( 'LaravelCommode\Common\CommodeCommonServiceProvider' ) ; } $ services = $ appServices -> differUnique ( $ this -> uses ( ) , true ) ; $ this -> services ( array_diff ( $ services , array_keys ( $ this -> app -> getLoadedProviders ( ) ) ) ) ; $ appServices -> register ( get_class ( $ this ) ) ; } ; $ this -> with ( ServiceShortCuts :: GHOST_SERVICE , $ withGhostServiceDo ) ; return $ this ; } | Prepares service for launching . If LaravelCommode \ Common \ CommodeCommonServiceProvider is not registered in your app config it will be forced to launch . Loads all services used by current GhostService instance . |
45,218 | protected function generateGrid ( $ tiles , $ columns ) { [ $ distribution , $ grid ] = Distributor :: distribute ( $ tiles , $ columns , $ this -> settings [ 'tallRate' ] , $ this -> settings [ 'wideRate' ] ) ; RandomFiller :: fill ( $ grid , $ distribution , $ this -> settings [ 'maxFillRetries' ] ) ; return $ grid ; } | Generate a Grid that contains a given number of columns . |
45,219 | public function load ( ServiceContainer $ container , array $ params ) { $ container -> define ( 'ecomdev.matcher.file' , function ( ) { return $ this -> createFileMatcher ( ) ; } , [ 'matchers' ] ) ; $ container -> define ( 'ecomdev.matcher.file_content' , function ( ) { return $ this -> createFileContentMatcher ( ) ; } , [ 'matchers' ] ) ; $ container -> define ( 'ecomdev.matcher.directory' , function ( ) { return $ this -> createDirectoryMatcher ( ) ; } , [ 'matchers' ] ) ; } | Loads matchers into PHPSpec service container |
45,220 | private function createCheckMatcher ( $ verbs , $ nouns , ... $ matcherArguments ) { return new CheckMatcher ( $ this -> createLexer ( $ verbs , $ nouns ) , ... $ matcherArguments ) ; } | Create check matcher instance |
45,221 | static public function instantiate ( RequestHelper $ requestHelper ) { $ objectHash = spl_object_hash ( $ requestHelper ) ; if ( static :: isSingleInstance ( ) ) { if ( isset ( static :: $ instances [ $ objectHash ] [ static :: getName ( ) ] ) ) { return static :: $ instances [ $ objectHash ] [ static :: getName ( ) ] ; } } $ instance = new static ( ) ; $ instance -> requestHelper = $ requestHelper ; $ instance -> initialize ( ) ; $ requestHelper -> getEventDispatcher ( ) -> dispatch ( RequestHelper :: EVENT_NEW_HELPER , new RequestHelperEvent ( $ requestHelper , array ( 'helper' => $ instance ) ) ) ; if ( static :: isSingleInstance ( ) ) { static :: $ instances [ $ objectHash ] [ static :: getName ( ) ] = $ instance ; } return $ instance ; } | Return a instance of himself . |
45,222 | public function deleteAcl ( $ object ) { try { if ( $ objectIdentity = $ this -> getObjectIdentity ( $ object ) ) { $ this -> aclProvider -> deleteAcl ( $ objectIdentity ) ; } } catch ( \ Exception $ e ) { } } | delete the ACL for the given object |
45,223 | public function files ( $ directory , $ recursive = false ) { $ result = [ ] ; $ recursive = boolval ( $ recursive ) ; if ( ! $ this -> isDirectory ( $ directory ) ) return [ ] ; $ items = new FilesystemIterator ( $ directory ) ; foreach ( $ items as $ item ) { if ( $ item -> isFile ( ) ) { $ result [ ] = $ item -> getPathname ( ) ; } elseif ( $ recursive && $ item -> isDir ( ) && ! $ item -> isLink ( ) ) { $ subFiles = $ this -> files ( $ item -> getPathname ( ) , $ recursive ) ; foreach ( $ subFiles as $ file ) { $ result [ ] = $ file ; } } } return $ result ; } | get all files in directory |
45,224 | public function buildGroups ( $ entities , $ level = 0 ) { if ( ! count ( $ this -> groupDefinitions ) ) { throw new \ RuntimeException ( 'There are no groups defined.' ) ; } $ groups = [ ] ; if ( ! isset ( $ this -> groupDefinitions [ $ level ] ) ) { return [ ] ; } $ groupDefinition = $ this -> groupDefinitions [ $ level ] ; $ entitiesByGroupUid = [ ] ; foreach ( $ entities as $ entity ) { $ groupUid = $ level . '-' . call_user_func ( $ groupDefinition -> getUidRetriever ( ) , $ entity ) ; if ( ! isset ( $ groups [ $ groupUid ] ) ) { $ groups [ $ groupUid ] = new Group ( $ groupUid , call_user_func ( $ groupDefinition -> getGroupDataFactory ( ) , $ entity ) , $ level , $ entity ) ; $ entitiesByGroupUid [ $ groupUid ] = [ ] ; } $ entitiesByGroupUid [ $ groupUid ] [ ] = $ entity ; } foreach ( $ entitiesByGroupUid as $ groupUid => $ iEntities ) { $ subGroups = $ this -> buildGroups ( $ iEntities , $ level + 1 ) ; foreach ( $ subGroups as $ subGroup ) { $ groups [ $ groupUid ] -> addChild ( $ subGroup ) ; } } $ columnDatasByGroupUid = [ ] ; foreach ( $ entitiesByGroupUid as $ groupUid => $ iEntities ) { if ( ! isset ( $ columnDatasByGroupUid [ $ groupUid ] ) ) { $ columnDatasByGroupUid [ $ groupUid ] = [ ] ; } } $ groupDefinition = $ this -> getGroup ( $ level ) ; foreach ( $ this -> getColumnDefinitions ( ) as $ columnId => $ columnDefinition ) { $ columnFoundInGroup = false ; foreach ( $ groupDefinition -> getColumnDefinitionsWithDataFactories ( ) as $ columnDefinitionsWithDataFactory ) { list ( $ groupColumnDefinition , $ columnDataFactory ) = $ columnDefinitionsWithDataFactory ; if ( $ columnDefinition -> equals ( $ groupColumnDefinition ) ) { foreach ( $ entitiesByGroupUid as $ groupUid => $ iEntities ) { $ columnDatasByGroupUid [ $ groupUid ] [ ] = $ columnDataFactory ( $ iEntities ) ; } $ columnFoundInGroup = true ; break ; } } if ( ! $ columnFoundInGroup ) { foreach ( $ entitiesByGroupUid as $ groupUid => $ iEntities ) { $ columnDatasByGroupUid [ $ groupUid ] [ ] = null ; } } } foreach ( $ columnDatasByGroupUid as $ groupUid => $ columnDatas ) { $ groups [ $ groupUid ] -> setColumnDatas ( $ columnDatas ) ; } $ finalGroups = array_values ( $ groups ) ; if ( ( $ sortingComparator = $ groupDefinition -> getSortingComparator ( ) ) !== null ) { usort ( $ finalGroups , $ sortingComparator ) ; } return $ finalGroups ; } | This method builds the whole structure . |
45,225 | public function addGlobalColumn ( ColumnDefinition $ columnDefinition , callable $ columnDataFactory ) { $ this -> addColumn ( $ columnDefinition ) ; foreach ( $ this -> groupDefinitions as $ groupDefinition ) { $ groupDefinition -> addColumn ( $ columnDefinition , $ columnDataFactory ) ; } return $ this ; } | This method adds column to groupie and to all available groups . IT SHOULD BE CALLED AFTER ALL GROUPS ARE ADDED! |
45,226 | public function addBuild ( Build $ build ) { $ this -> getBuilds ( ) ; $ build -> setRepositoryId ( $ this -> getId ( ) ) ; $ this -> builds [ $ build -> getId ( ) ] = $ build ; } | Add build to the list |
45,227 | public function removeBuild ( Build $ build ) { if ( isset ( $ this -> builds [ $ build -> getId ( ) ] ) ) { unset ( $ this -> builds [ $ build -> getId ( ) ] ) ; } } | Remove build from the list |
45,228 | public static function jsonDeserialize ( array $ json ) : DocumentSerializationInterface { $ managerClass = $ json [ 'document_serialization' ] [ 'manager_class' ] ; $ data = ( array ) $ json [ 'document_serialization' ] [ 'data' ] ; return new self ( $ managerClass , $ data ) ; } | Deserialize the data |
45,229 | public static function invoke ( $ jsonString , $ returnNode = false ) { $ dom = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ jsonString = mb_convert_encoding ( $ jsonString , 'UTF-8' , mb_detect_encoding ( $ jsonString ) ) ; $ jsonDecode = json_decode ( $ jsonString , false ) ; $ lastError = json_last_error ( ) ; if ( JSON_ERROR_NONE === $ lastError ) { $ ul = $ dom -> createElement ( 'ul' ) ; $ ul -> setAttribute ( 'class' , 'json-list' ) ; $ dom -> appendChild ( $ ul ) ; if ( $ jsonDecode instanceof \ stdClass ) self :: objectOutput ( $ jsonDecode , $ dom , $ ul ) ; else if ( is_array ( $ jsonDecode ) ) self :: arrayOutput ( $ jsonDecode , $ dom , $ ul ) ; if ( $ returnNode ) return $ dom ; return static :: saveHTMLExact ( $ dom , $ ul ) ; } throw new \ DomainException ( sprintf ( 'Could not convert input to HTML: "%s"' , JsonErrorHelper :: invoke ( true , $ lastError ) ) ) ; } | Invoke the helper |
45,230 | protected static function objectOutput ( \ stdClass $ object , \ DOMDocument $ dom , \ DOMElement $ parentUL ) { foreach ( $ object as $ k => $ v ) { $ li = $ dom -> createElement ( 'li' ) ; $ parentUL -> appendChild ( $ li ) ; $ strong = $ dom -> createElement ( 'strong' , $ k ) ; $ li -> appendChild ( $ strong ) ; if ( $ v instanceof \ stdClass ) { $ ul = $ dom -> createElement ( 'ul' ) ; $ li -> appendChild ( $ ul ) ; self :: objectOutput ( $ v , $ dom , $ ul ) ; } else if ( is_array ( $ v ) ) { $ ul = $ dom -> createElement ( 'ul' ) ; $ li -> appendChild ( $ ul ) ; self :: arrayOutput ( $ v , $ dom , $ ul ) ; } else if ( is_bool ( $ v ) ) { switch ( $ v ) { case true : $ li -> appendChild ( $ dom -> createTextNode ( ' TRUE' ) ) ; break ; case false : $ li -> appendChild ( $ dom -> createTextNode ( ' FALSE' ) ) ; break ; } } else if ( is_scalar ( $ v ) ) { $ span = $ dom -> createElement ( 'span' ) ; $ span -> appendChild ( $ dom -> createTextNode ( ' ' . strval ( $ v ) ) ) ; $ li -> appendChild ( $ span ) ; } } return $ dom ; } | Parse through json object |
45,231 | public function applyFilters ( QueryBuilder $ queryBuilder , $ alias , FilterBagInterface $ filterBag = null ) { if ( is_null ( $ filterBag ) ) { return $ queryBuilder ; } foreach ( $ filterBag -> all ( ) as $ filter ) { if ( $ filter instanceof FilterNode ) { $ this -> applyFilter ( $ queryBuilder , $ alias , $ filter ) ; } } return $ queryBuilder ; } | Apply filters from a filter bag on the provided query builder |
45,232 | protected function applyFilter ( QueryBuilder $ queryBuilder , $ alias , FilterNode $ filter ) { $ queryBuilderPatcher = new QueryBuilderPatcher ( new QueryExpressionBuilder ( ) ) ; return $ queryBuilderPatcher -> patch ( $ queryBuilder , $ filter , new QueryContext ( $ alias ) ) ; } | Apply one filter to the query builder |
45,233 | public function addErrorMessage ( $ message , $ params = array ( ) ) { $ message = $ this -> trans ( $ message , $ params ) ; static :: $ messages [ ] = array ( 'type' => 'error' , 'bootstrapType' => 'danger' , 'message' => $ message ) ; static :: $ success = false ; } | add a error message to the api call |
45,234 | public function addSuccessMessage ( $ message , $ params = array ( ) ) { $ message = $ this -> trans ( $ message , $ params ) ; static :: $ messages [ $ message ] = array ( 'type' => 'success' , 'bootstrapType' => 'success' , 'message' => $ message ) ; } | add a success message to the api call |
45,235 | public function addInfoMessage ( $ message , $ params = array ( ) ) { $ message = $ this -> trans ( $ message , $ params ) ; static :: $ messages [ ] = array ( 'type' => 'info' , 'bootstrapType' => 'info' , 'message' => $ message ) ; } | add a info message to the api call |
45,236 | public function addWarningMessage ( $ message , $ params = array ( ) ) { $ message = $ this -> trans ( $ message , $ params ) ; static :: $ messages [ ] = array ( 'type' => 'warning' , 'bootstrapType' => 'warning' , 'message' => $ message ) ; } | add a warning message to the api |
45,237 | public function execute ( Framework $ framework , WebRequest $ request , Response $ response ) { $ renderedOutput = $ this -> render ( '\\Zepi\\Web\\AccessControl\\Templates\\NoAccessMessage' ) ; $ response -> setOutput ( $ renderedOutput ) ; } | Displays a message if the session has no access to the requested command . |
45,238 | public function getPropertyAnnotation ( \ ReflectionProperty $ property ) { $ annot = $ this -> reader -> getPropertyAnnotation ( $ property , '\Represent\Annotations\Property' ) ; if ( ! $ annot ) { return false ; } return $ annot ; } | Returns the property annotation or false if one is not present ; |
45,239 | public function getSerializedName ( \ ReflectionProperty $ property , Property $ annot = null ) { if ( $ annot || $ annot = $ this -> getPropertyAnnotation ( $ property ) ) { return $ annot -> getName ( ) ; } return $ property -> getName ( ) ; } | Returns the serialized name for this property |
45,240 | public function propertyTypeOverride ( Property $ annot = null , \ ReflectionProperty $ property = null ) { if ( $ annot || $ annot = $ this -> getPropertyAnnotation ( $ property ) ) { return $ annot -> getType ( ) ; } return null ; } | Returns the type this property is changed to during serialization or false if no conversion occurs |
45,241 | public function getConvertedValue ( \ ReflectionProperty $ property , $ original , Property $ annot = null ) { return $ this -> handleTypeConversion ( $ this -> propertyTypeOverride ( $ annot , $ property ) , $ property -> getValue ( $ original ) ) ; } | Returns the value used for serialization from a reflection property |
45,242 | protected function formatAttributeValue ( Attribute $ attribute ) { $ value = $ attribute -> getValue ( ) ; if ( $ attribute -> getType ( ) === Attribute :: TYPE_FUNCTION && strlen ( $ value ) ) { return new Expr ( $ value ) ; } return $ value ; } | Formats attributes value |
45,243 | public function getAvatarAttribute ( ) { $ hash = ! empty ( $ this -> email ) ? md5 ( strtolower ( trim ( $ this -> email ) ) ) : '' ; return sprintf ( '//secure.gravatar.com/avatar/%s?d=mm' , $ hash ) ; } | Get the avatar url from Gravatar |
45,244 | private function prepareParametersUrl ( array $ params , array $ allowedParams ) { $ allowedParams = array_flip ( $ allowedParams ) ; $ params = array_intersect_key ( $ params , $ allowedParams ) ; $ paramsUrlItems = [ ] ; foreach ( $ params as $ key => $ param ) { $ paramsUrlItems [ ] = $ key . '=' . urlencode ( $ param ) ; } $ paramsUrl = join ( '&' , $ paramsUrlItems ) ; if ( strlen ( $ paramsUrl ) > 0 ) { $ paramsUrl = '?' . $ paramsUrl ; } return $ paramsUrl ; } | Prepares params url that can be appended to request . |
45,245 | public final function on ( $ eventName , $ eventCallback ) { if ( ! is_string ( $ eventName ) ) { throw new \ browserfs \ Exception ( 'Invalid argument $eventName: string expected' ) ; } else { if ( ! strlen ( $ eventName ) ) { throw new \ browserfs \ Exception ( 'Invalid argument $eventName: expected non-empty string' ) ; } else { if ( ! is_callable ( $ eventCallback ) ) { throw new \ browserfs \ Exception ( 'Invalid argument $eventCallback: callable expected' ) ; } else { $ this -> events [ $ eventName ] = isset ( $ this -> events [ $ eventName ] ) ? $ this -> events [ $ eventName ] : [ ] ; $ this -> events [ $ eventName ] [ ] = [ 'once' => false , 'callback' => $ eventCallback , 'fireId' => 0 ] ; } } } } | Adds a event listener . |
45,246 | public final function once ( $ eventName , $ eventCallback ) { if ( ! is_string ( $ eventName ) ) { throw new \ browserfs \ Exception ( 'Invalid argument $eventName: string expected' ) ; } else { if ( ! strlen ( $ eventName ) ) { throw new \ browserfs \ Exception ( 'Invalid argument $eventName: expected non-empty string' ) ; } else { if ( ! is_callable ( $ eventCallback ) ) { throw new \ browserfs \ Exception ( 'Invalid argument $eventCallback: callable expected' ) ; } else { $ this -> events [ $ eventName ] = isset ( $ this -> events [ $ eventName ] ) ? $ this -> events [ $ eventName ] : [ ] ; $ this -> events [ $ eventName ] [ ] = [ 'once' => true , 'callback' => $ eventCallback , 'fireId' => 0 ] ; } } } } | Adds a event listener that will be fired only once . |
45,247 | private static function callbackEquals ( $ callback1 , $ callback2 ) { if ( is_array ( $ callback1 ) && is_array ( $ callback2 ) ) { if ( count ( $ callback1 ) == count ( $ callback2 ) ) { for ( $ i = 0 , $ len = count ( $ callback1 ) ; $ i < $ len ; $ i ++ ) { if ( $ callback1 [ $ i ] != $ callback2 [ $ i ] ) { return false ; } } return true ; } else { return false ; } } else { return $ callback1 == $ callback2 ; } } | Helper to compare if two callbacks are equal . |
45,248 | public final function off ( $ eventName , $ eventCallback = null ) { if ( is_string ( $ eventName ) ) { if ( strlen ( $ eventName ) > 0 ) { if ( isset ( $ this -> events [ $ eventName ] ) ) { if ( $ eventCallback === null ) { unset ( $ this -> events [ $ eventName ] ) ; } else { for ( $ i = count ( $ this -> events [ $ eventName ] ) - 1 ; $ i >= 0 ; $ i -- ) { if ( self :: callbackEquals ( $ eventCallback , $ this -> events [ $ eventName ] [ $ i ] [ 'callback' ] ) ) { array_splice ( $ this -> events [ $ eventName ] , $ i , 1 ) ; if ( count ( $ this -> events [ $ eventName ] ) == 0 ) { unset ( $ this -> events [ $ eventName ] ) ; } break ; } } } } } else { throw new \ browserfs \ Exception ( 'Invalid argument $eventName: non-empty string expected!' ) ; } } else { throw new \ browserfs \ Exception ( 'Invalid argument $eventName: string expected!' ) ; } } | Removes a event listener callback binded to eventName |
45,249 | public final function fire ( $ eventName ) { if ( ! is_string ( $ eventName ) ) { throw new \ browserfs \ Exception ( 'Invalid argument $eventName: string expected' ) ; } else if ( ! strlen ( $ eventName ) ) { throw new \ browserfs \ Exception ( 'Invalid argument $eventName: non-empty string expected' ) ; } if ( ! isset ( $ this -> events [ $ eventName ] ) ) { return ; } $ eventArgs = array_slice ( func_get_args ( ) , 1 ) ; $ event = Event :: create ( $ eventName , $ eventArgs ) ; try { $ this -> fireId ++ ; $ copy = [ ] ; foreach ( $ this -> events [ $ eventName ] as & $ subscriber ) { $ copy [ ] = & $ subscriber ; } foreach ( $ copy as & $ subscriber ) { $ subscriber [ 'fireId' ] = $ this -> fireId ; call_user_func ( $ subscriber [ 'callback' ] , $ event ) ; if ( $ event -> isPropagationStopped ( ) ) { break ; } } if ( isset ( $ this -> events [ $ eventName ] ) ) { for ( $ i = count ( $ this -> events [ $ eventName ] ) - 1 ; $ i >= 0 ; $ i -- ) { if ( $ this -> events [ $ eventName ] [ $ i ] [ 'fireId' ] === $ this -> fireId ) { if ( $ this -> events [ $ eventName ] [ $ i ] [ 'once' ] === true ) { array_splice ( $ this -> events [ $ eventName ] , $ i , 1 ) ; } } } } } catch ( \ Exception $ e ) { throw new \ browserfs \ Exception ( "Error firing event " . $ eventName , 0 , $ e ) ; } return $ event ; } | Fires a event and returns it s generated event object . |
45,250 | public function findNextSubcategory ( $ subcategory ) { $ qb = $ this -> getQueryBuilder ( ) -> select ( 'c' ) -> where ( 'c.id > :id' ) -> andWhere ( 'c.parentCategory = :parentCategory' ) -> orderBy ( 'c.id' , 'asc' ) -> setMaxResults ( 1 ) -> setParameter ( 'id' , $ subcategory -> getId ( ) ) -> setParameter ( 'parentCategory' , $ subcategory -> getParentCategory ( ) ) ; if ( 0 == count ( $ qb -> getQuery ( ) -> getResult ( ) ) ) { $ qb -> where ( 'c.id < :id' ) -> andWhere ( 'c.parentCategory = :parentCategory' ) -> setParameter ( 'id' , $ subcategory -> getId ( ) ) -> setParameter ( 'parentCategory' , $ subcategory -> getParentCategory ( ) ) ; if ( 0 == count ( $ qb -> getQuery ( ) -> getResult ( ) ) ) { return null ; } } return $ qb -> getQuery ( ) -> getSingleResult ( ) ; } | Find the next subcategory or the first one if none is found |
45,251 | public function getBrands ( $ category , $ limit = null ) { $ qb = $ this -> getQueryBuilder ( ) -> select ( 'DISTINCT b.id, b.name' ) -> innerJoin ( 'c.products' , 'p' ) -> innerJoin ( 'p.brand' , 'b' ) -> where ( 'p.active = TRUE' ) -> andWhere ( 'b.available = TRUE' ) ; if ( $ category -> getFamily ( ) ) { $ qb -> andWhere ( 'c.parentCategory = :category' ) -> setParameter ( 'category' , $ category ) ; } else { $ qb -> andWhere ( 'c = :category' ) -> setParameter ( 'category' , $ category ) ; } if ( ! is_null ( $ limit ) ) { $ qb -> setMaxResults ( $ limit ) ; } return $ qb -> getQuery ( ) -> getResult ( ) ; } | Get brands from their products relationship |
45,252 | public function find ( $ paths = null ) { if ( $ paths === null ) $ paths = $ this -> paths ; $ iterator = $ this -> getIterator ( ) ; foreach ( ( array ) $ paths as $ path ) { $ this -> searchInPath ( $ iterator , $ path ) ; } $ this -> clear ( ) ; return $ iterator ; } | find trigger . |
45,253 | private function searchInPath ( FileSystem \ Iterator \ IteratorAggregate $ iterator , $ path , FileSystem \ Directory $ parent = null , $ depth = 0 ) { if ( file_exists ( $ path ) ) { if ( is_dir ( $ path ) ) { $ dir = new FileSystem \ Directory ( $ path ) ; if ( $ parent ) $ dir -> setParent ( $ parent ) ; if ( $ this -> validate ( $ dir ) ) $ iterator -> add ( $ dir ) ; if ( $ this -> recursive || $ depth < 1 ) { $ this -> searchInPath ( $ iterator , "{$dir}/*" , $ dir , $ depth + 1 ) ; } } else { $ file = new FileSystem \ File ( $ path ) ; if ( $ parent ) $ file -> setParent ( $ parent ) ; if ( $ this -> validate ( $ file ) ) $ iterator -> add ( $ file ) ; } } else { foreach ( glob ( $ path ) as $ file ) { $ this -> searchInPath ( $ iterator , $ file , $ parent , $ depth ) ; } } } | search files in target path . |
45,254 | private function validate ( FileSystem \ File $ file ) { $ filters = $ this -> buildFilters ( ) ; foreach ( $ filters as $ filter ) { if ( ! $ filter -> validate ( $ file ) ) return false ; } return true ; } | validate file . |
45,255 | private function buildFilters ( ) { $ filters = array ( ) ; if ( $ this -> file_only ) $ filters [ ] = new Filter \ FileOnlyFilter ( ) ; if ( $ this -> directory_only ) $ filters [ ] = new Filter \ DirectoryOnlyFilter ( ) ; foreach ( $ this -> names as $ name ) { $ filters [ ] = new Filter \ NameFilter ( $ name ) ; } return $ filters ; } | build filters for validate . |
45,256 | public function fileOnly ( $ flag = true ) { $ this -> file_only = $ flag ; if ( $ this -> file_only ) $ this -> directory_only = false ; return $ this ; } | set file only flag is true |
45,257 | public function directoryOnly ( $ flag = true ) { $ this -> directory_only = $ flag ; if ( $ this -> directory_only ) $ this -> file_only = false ; return $ this ; } | set directory only is true . |
45,258 | public function removeListener ( Listener $ listener ) { foreach ( $ this -> listeners as $ id => $ listening ) { if ( $ listener == $ listening ) { unset ( $ this -> listeners [ $ id ] ) ; break ; } } } | Remove a Listener Object |
45,259 | public function login ( $ nick , $ password = null ) { if ( $ password ) { if ( ! $ this -> connection -> send ( "PASS {$password}" ) ) { throw new \ RuntimeException ( "failed to send password to {$this->server}" ) ; } } else { if ( ! $ this -> connection -> send ( "PASS NOPASS" ) ) { throw new \ RuntimeException ( "failed to send nopass to {$this->server}" ) ; } } if ( ! $ this -> connection -> send ( "NICK {$nick}" ) ) { throw new \ RuntimeException ( "failed to set nick {$nick} on {$this->server}" ) ; } $ this -> loop ( false ) ; if ( ! $ this -> connection -> send ( "USER {$nick} AS IRC BOT" ) ) { throw new \ RuntimeException ( "failed to set user {$nick} on {$this->server}" ) ; } $ this -> loop ( false ) ; return $ this ; } | Login into server as nick with optional password |
45,260 | public function loop ( $ main = true ) { if ( $ main && $ this -> manager ) { $ this -> manager -> onStartup ( $ this ) ; } while ( ( $ line = $ this -> connection -> recv ( ) ) ) { if ( preg_match ( "~^ping :(.*)?~i" , $ line , $ pong ) ) { if ( ! $ this -> connection -> send ( "PONG {$pong[1]}" ) ) { throw new \ RuntimeException ( "failed to send PONG to {$this->server}" ) ; } } else { $ message = new Message ( $ line ) ; if ( $ main && $ this -> manager ) { switch ( $ message -> getType ( ) ) { case Message :: join : $ this -> manager -> onJoin ( $ this , $ message ) ; break ; case Message :: part : $ this -> manager -> onPart ( $ this , $ message ) ; break ; case Message :: nick : $ this -> manager -> onNick ( $ this , $ message ) ; break ; case Message :: priv : $ this -> manager -> onPriv ( $ this , $ message ) ; break ; } } foreach ( $ this -> listeners as $ listener ) { $ response = $ listener -> onReceive ( $ this -> connection , $ message ) ; if ( $ response ) { if ( ( $ response instanceof Task ) ) { $ this -> pool -> submit ( $ response ) ; continue ; } throw new \ RuntimeException ( sprintf ( "%s returned an invalid response, " . "expected Task object or nothing" , get_class ( $ listener ) ) ) ; } } } if ( ! $ main ) break ; $ this -> pool -> collect ( function ( $ responder ) { if ( $ responder instanceof Task ) { return $ responder -> isGarbage ( ) ; } else return true ; } ) ; } if ( $ main && $ this -> manager ) { $ this -> manager -> onShutdown ( $ this ) ; } return $ main ? $ this -> loop ( $ main ) : $ this ; } | Enter into IO loop |
45,261 | protected function createServiceFactory ( $ requestedName , ReflectionClass $ reflection , ContainerInterface $ container ) { $ mappings = $ this -> getServiceMapping ( $ container , $ requestedName ) ; if ( $ reflection -> implementsInterface ( Factory \ FactoryInterface :: class ) ) { $ factory = $ reflection -> newInstance ( $ mappings [ 'namespace' ] , $ mappings [ 'service' ] , $ this -> namespace ) ; } else { $ factory = $ reflection -> newInstance ( ) ; } $ this -> lookupCache [ $ requestedName ] [ 'factoryInstance' ] = $ factory ; if ( $ factory instanceof Factory \ FactoryInterface ) { $ factory -> setContainer ( $ container ) ; } return $ factory ( $ container , $ requestedName ) ; } | Initiate service factory from the ReflectionClass . |
45,262 | protected static function iterateFileName ( string $ fileName ) { $ arrFileParts = explode ( "." , $ fileName ) ; $ extension = array_pop ( $ arrFileParts ) ; $ tempFileName = implode ( "." , $ arrFileParts ) ; $ arrFileName = explode ( "_" , $ tempFileName ) ; if ( is_numeric ( $ arrFileName [ ( count ( $ arrFileName ) - 1 ) ] ) ) { $ iterator = ( int ) array_pop ( $ arrFileName ) ; $ iterator ++ ; $ arrFileName [ ] = $ iterator ; $ newFileName = implode ( "_" , $ arrFileName ) ; return $ newFileName . "." . $ extension ; } return $ tempFileName . "_1." . $ extension ; } | Puts a number on the end of a file name prevents overwriting |
45,263 | public function authenticate ( $ params , $ method , $ headers ) { $ email = \ Phramework \ Validate \ EmailValidator :: parseStatic ( $ params [ 'email' ] ) ; $ password = $ params [ 'password' ] ; $ user = call_user_func ( Manager :: getUserGetByEmailMethod ( ) , $ email ) ; if ( ! $ user ) { return false ; } if ( ! password_verify ( $ password , $ user [ 'password' ] ) ) { return false ; } $ data = [ 'id' => $ user [ 'id' ] ] ; foreach ( Manager :: getAttributes ( ) as $ attribute ) { if ( ! isset ( $ user [ $ attribute ] ) ) { throw new \ Phramework \ Exceptions \ ServerException ( sprintf ( 'Attribute "%s" is not set in user object' , $ attribute ) ) ; } $ data [ $ attribute ] = $ user [ $ attribute ] ; } $ data = ( object ) $ data ; if ( ( $ callback = Manager :: getOnAuthenticateCallback ( ) ) !== null ) { call_user_func ( $ callback , $ data ) ; } return [ $ data ] ; } | Authenticate a user using JWT authentication method |
45,264 | public function set ( $ prop , $ value ) { $ class = get_class ( $ this ) ; if ( property_exists ( $ class , $ prop ) ) { $ reflection = new \ ReflectionProperty ( $ class , $ prop ) ; $ reflection -> setAccessible ( true ) ; $ reflection -> setValue ( $ this , $ value ) ; } else { $ msg = sprintf ( "Unexpected data set `%s` on `%s`" , $ prop , $ class ) ; throw new ContextException ( $ msg ) ; } return $ this ; } | Set context data |
45,265 | public function addCondition ( $ field , $ value = false , $ operator = '=' ) { if ( is_array ( $ field ) && ! $ value ) { foreach ( $ field as $ key => $ value ) { if ( is_array ( $ value ) ) { call_user_func_array ( [ $ this , 'addCondition' ] , $ value ) ; } elseif ( ! is_numeric ( $ key ) ) { $ this -> addCondition ( $ key , $ value ) ; } else { $ this -> addCondition ( $ value ) ; } } return $ this ; } $ condition = [ $ field ] ; if ( func_num_args ( ) >= 2 ) { $ condition [ ] = $ operator ; $ condition [ ] = $ value ; } $ this -> conditions [ ] = $ condition ; return $ this ; } | Adds a condition to the statement . |
45,266 | public function addBetweenCondition ( $ field , $ a , $ b ) { $ this -> conditions [ ] = [ 'BETWEEN' , $ field , $ a , $ b , true ] ; return $ this ; } | Adds a between condition to the query . |
45,267 | public function addNotBetweenCondition ( $ field , $ a , $ b ) { $ this -> conditions [ ] = [ 'BETWEEN' , $ field , $ a , $ b , false ] ; return $ this ; } | Adds a not between condition to the query . |
45,268 | protected function buildClause ( array $ cond ) { if ( count ( $ cond ) == 1 && ( is_string ( $ cond [ 0 ] ) || ! is_callable ( $ cond [ 0 ] ) ) ) { return $ cond [ 0 ] ; } if ( $ cond [ 0 ] === 'EXISTS' ) { return $ this -> buildExists ( $ cond [ 1 ] , $ cond [ 2 ] ) ; } if ( $ cond [ 0 ] === 'BETWEEN' ) { return $ this -> buildBetween ( $ cond [ 1 ] , $ cond [ 2 ] , $ cond [ 3 ] , $ cond [ 4 ] ) ; } if ( is_string ( $ cond [ 0 ] ) || ! is_callable ( $ cond [ 0 ] ) ) { $ cond [ 0 ] = $ this -> escapeIdentifier ( $ cond [ 0 ] ) ; } elseif ( is_callable ( $ cond [ 0 ] ) ) { $ cond [ 0 ] = $ this -> buildSubquery ( $ cond [ 0 ] ) ; } if ( count ( $ cond ) === 1 || empty ( $ cond [ 0 ] ) ) { return $ cond [ 0 ] ; } if ( $ cond [ 2 ] === null && in_array ( $ cond [ 1 ] , [ '=' , '<>' ] ) ) { return $ this -> buildNull ( $ cond [ 0 ] , $ cond [ 1 ] == '=' ) ; } if ( is_array ( $ cond [ 2 ] ) && in_array ( $ cond [ 1 ] , [ '=' , '<>' ] ) ) { return $ this -> buildIn ( $ cond [ 0 ] , $ cond [ 2 ] , $ cond [ 1 ] == '=' ) ; } $ cond [ 2 ] = $ this -> parameterize ( $ cond [ 2 ] ) ; return implode ( ' ' , $ cond ) ; } | Builds a parameterized and escaped SQL fragment for a condition that uses our own internal representation . |
45,269 | protected function buildSubquery ( callable $ f ) { $ query = new SelectQuery ( ) ; $ query -> getSelect ( ) -> clearFields ( ) ; $ f ( $ query ) ; $ sql = $ query -> build ( ) ; $ this -> values = array_merge ( $ this -> values , $ query -> getValues ( ) ) ; return '(' . $ sql . ')' ; } | Builds a subquery . |
45,270 | protected function buildBetween ( $ field , $ value1 , $ value2 , $ isBetween ) { $ operator = $ isBetween ? 'BETWEEN' : 'NOT BETWEEN' ; return $ this -> escapeIdentifier ( $ field ) . ' ' . $ operator . ' ' . $ this -> parameterize ( $ value1 ) . ' AND ' . $ this -> parameterize ( $ value2 ) ; } | Builds a BETWEEN clause . |
45,271 | protected function buildIn ( $ field , array $ values , $ isIn ) { $ operator = $ isIn ? ' IN ' : ' NOT IN ' ; return $ field . $ operator . $ this -> parameterizeValues ( $ values ) ; } | Builds an IN clause . |
45,272 | protected function implodeClauses ( array $ clauses ) { $ str = '' ; $ op = false ; foreach ( $ clauses as $ clause ) { if ( $ clause == 'OR' ) { $ op = ' OR ' ; continue ; } if ( $ op && $ str ) { $ str .= $ op ; } $ str .= $ clause ; $ op = ' AND ' ; } return $ str ; } | Implodes a list of WHERE clauses . |
45,273 | protected function export ( string $ key , $ value ) { $ container = JinitializeContainer :: getInstance ( ) ; $ container -> getPlugin ( $ this -> getPluginName ( ) ) -> getContainer ( ) -> set ( $ key , $ value ) ; } | Save a value to the application container |
45,274 | protected function import ( string $ key ) { $ container = JinitializeContainer :: getInstance ( ) ; return $ container -> getPlugin ( $ this -> getPluginName ( ) ) -> getContainer ( ) -> get ( $ key ) ; } | Get a value from the local plugin container |
45,275 | public static function getImageInfo ( $ image , array $ config = null ) { $ finfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ img = new static ( $ image [ 'value' ] , $ finfo , $ config ) ; $ curl = $ img -> getConnection ( ) ; curl_exec ( $ curl ) ; curl_close ( $ curl ) ; $ info = $ img -> getInfo ( ) ; finfo_close ( $ finfo ) ; return $ info ; } | Get the info of only one image |
45,276 | public function writeCallback ( $ connection , $ string ) { $ this -> content .= $ string ; if ( ! $ this -> mime ) { $ this -> mime = finfo_buffer ( $ this -> finfo , $ this -> content ) ; if ( ! in_array ( $ this -> mime , static :: $ mimetypes , true ) ) { $ this -> mime = null ; return - 1 ; } } if ( ! ( $ info = getimagesizefromstring ( $ this -> content ) ) ) { return strlen ( $ string ) ; } $ this -> info = [ 'width' => $ info [ 0 ] , 'height' => $ info [ 1 ] , 'size' => $ info [ 0 ] * $ info [ 1 ] , 'mime' => $ this -> mime , ] ; return - 1 ; } | Callback used to save the first bytes of the body content |
45,277 | public function delete ( ) { if ( ! $ this -> exists ( ) ) { return false ; } if ( $ this -> isDir ( ) ) { return rmdir ( $ this -> absoluteFileName ) ; } return unlink ( $ this -> absoluteFileName ) ; } | tries to delete a file |
45,278 | public function createDir ( $ mode = 0777 ) { return is_dir ( $ this -> absoluteFileName ) || mkdir ( $ this -> absoluteFileName , $ mode , true ) ; } | creates needed directories recursively |
45,279 | public function scanDir ( ) { if ( ! $ this -> isDir ( ) || ! $ this -> exists ( ) ) { return null ; } $ fileList = [ ] ; $ fileNameList = scandir ( $ this -> absoluteFileName ) ; foreach ( $ fileNameList as $ fileName ) { if ( $ fileName === "." or $ fileName === ".." ) { continue ; } $ absoluteFileName = $ this -> absoluteFileName . "/" . $ fileName ; $ fileList [ ] = new File ( $ absoluteFileName ) ; } return $ fileList ; } | scans a directory and returns a list of Files |
45,280 | public function findFirstOccurenceOfFile ( string $ fileName ) { if ( ! $ this -> isDir ( ) || ! $ this -> exists ( ) ) { return null ; } foreach ( $ this -> scanDir ( ) as $ file ) { if ( $ file -> getFileName ( ) === $ fileName ) { return $ file ; } if ( $ file -> isDir ( ) ) { $ result = $ file -> findFirstOccurenceOfFile ( $ fileName ) ; if ( $ result !== null ) { return $ result ; } } } return null ; } | Finds the first occurence of the given filename |
45,281 | public function loadAsXSLTProcessor ( ) { $ this -> checkFileExists ( ) ; $ xsl = new \ XSLTProcessor ( ) ; $ xsl -> importStylesheet ( $ this -> loadAsXML ( ) ) ; return $ xsl ; } | loads the file as XSLT Processor |
45,282 | public function loadAsXML ( ) { $ this -> checkFileExists ( ) ; $ xml = new \ DomDocument ( ) ; libxml_use_internal_errors ( true ) ; $ result = $ xml -> load ( $ this -> absoluteFileName ) ; if ( $ result ) { return $ xml ; } $ messageObject = ArrayUtil :: getFromArray ( libxml_get_errors ( ) , 0 ) ; $ libXMLMessage = ObjectUtil :: getFromObject ( $ messageObject , "message" ) ; $ message = sprintf ( self :: EXCEPTION_INVALID_XML , $ this -> absoluteFileName , $ libXMLMessage ) ; $ e = new \ Exception ( libxml_get_errors ( ) [ 0 ] -> message ) ; libxml_clear_errors ( ) ; throw $ e ; } | loads the file as XML DOMDocument |
45,283 | public function elementShouldBeVisible ( $ selector ) { $ session = $ this -> getSession ( ) ; $ page = $ session -> getPage ( ) ; $ element = $ page -> find ( 'css' , $ selector ) ; if ( ! $ element ) { throw new ElementNotFoundException ( $ session , 'Element "' . $ selector . '"' ) ; } \ PHPUnit_Framework_TestCase :: assertTrue ( $ element -> isVisible ( ) ) ; } | Checks an element is visible |
45,284 | public function elementShouldBeHidden ( $ selector ) { $ session = $ this -> getSession ( ) ; $ page = $ session -> getPage ( ) ; $ element = $ page -> find ( 'css' , $ selector ) ; if ( ! $ element ) { throw new ElementNotFoundException ( $ session , 'Element "' . $ selector . '"' ) ; } \ PHPUnit_Framework_TestCase :: assertFalse ( $ element -> isVisible ( ) ) ; } | Checks an element is hidden |
45,285 | public function elementShouldHaveClass ( $ selector , $ class ) { $ session = $ this -> getSession ( ) ; $ page = $ session -> getPage ( ) ; $ element = $ page -> find ( 'css' , $ selector ) ; if ( ! $ element ) { throw new ElementNotFoundException ( $ session , 'Element "' . $ selector . '"' ) ; } \ PHPUnit_Framework_TestCase :: assertTrue ( $ element -> hasClass ( $ class ) ) ; } | Checks an element has a class |
45,286 | public function elementShouldNotHaveClass ( $ selector , $ class ) { $ session = $ this -> getSession ( ) ; $ page = $ session -> getPage ( ) ; $ element = $ page -> find ( 'css' , $ selector ) ; if ( ! $ element ) { throw new ElementNotFoundException ( $ session , 'Element "' . $ selector . '"' ) ; } \ PHPUnit_Framework_TestCase :: assertFalse ( $ element -> hasClass ( $ class ) ) ; } | Checks an element doesn t have a class |
45,287 | public function addJs ( $ js ) { if ( is_array ( $ js ) ) { foreach ( $ js as $ script ) { $ this -> addJs ( $ script ) ; } return $ this ; } $ this -> js -> push ( $ js ) ; return $ this ; } | Add a javascript dependency on the view . |
45,288 | public function getClassLoaders ( ) { if ( null !== static :: $ classLoaders ) { return static :: $ classLoaders ; } static :: $ classLoaders = array ( ) ; foreach ( spl_autoload_functions ( ) as $ function ) { if ( is_array ( $ function ) && count ( $ function [ 0 ] ) > 0 && is_object ( $ function [ 0 ] ) && 'Composer\Autoload\ClassLoader' === get_class ( $ function [ 0 ] ) ) { static :: $ classLoaders [ ] = $ function [ 0 ] ; } } return static :: $ classLoaders ; } | Locate all Composer Autoload ClassLoader instances |
45,289 | public function migrateTask ( Option $ option ) { $ databases = $ this -> getDatabases ( $ option ) ; $ start = microtime ( true ) ; foreach ( $ databases as $ alias => $ database ) { $ manager = $ this -> getManager ( $ alias , $ database ) ; $ manager -> migrate ( $ this -> application -> getEnv ( ) , $ option -> getArg ( 0 ) ) ; } $ end = microtime ( true ) ; $ this -> sendMessage ( '' ) ; $ this -> sendMessage ( 'All Done. Took %.4fs' , $ end - $ start ) ; $ this -> task ( 'db:schema:dump' , $ option -> copy ( ) ) ; } | database migration task . using phinx . |
45,290 | public function seedTask ( Option $ option ) { $ name = $ option -> getArg ( 0 ) ; $ databases = $ this -> getDatabases ( $ option ) ; $ start = microtime ( true ) ; foreach ( $ databases as $ alias => $ database ) { foreach ( $ this -> migrationHelper -> getSeeders ( $ alias , $ name ) as $ seeder ) { try { $ this -> sendMessage ( 'seeding... -> %s' , $ seeder -> getName ( ) ) ; $ seeder -> seed ( ) ; } catch ( \ Exception $ e ) { $ this -> sendMessage ( $ e -> getMessage ( ) ) ; $ this -> sendMessage ( 'has error. aborting.' ) ; return ; } } } $ end = microtime ( true ) ; $ this -> sendMessage ( '' ) ; $ this -> sendMessage ( 'All Done. Took %.4fs' , $ end - $ start ) ; } | database seeding task . |
45,291 | public function statusTask ( Option $ option ) { $ databases = $ this -> getDatabases ( $ option ) ; foreach ( $ databases as $ alias => $ database ) { $ manager = $ this -> getManager ( $ alias , $ database ) ; $ manager -> printStatus ( $ this -> application -> getEnv ( ) , $ option -> get ( 'format' ) ) ; } } | show database mgration status task . using phinx . |
45,292 | public function setModel ( $ model ) { $ model -> setSerializeNull ( $ this -> isSerializeNull ( ) ) ; $ this -> setJson ( $ model -> toJson ( ) ) ; return $ this ; } | Set Model . |
45,293 | public function onKernelException ( GetResponseForExceptionEvent $ event ) { $ exception = $ event -> getException ( ) ; $ response = null ; switch ( true ) { case ( $ exception instanceof NotFoundHttpException ) : $ response = $ this -> createNotFoundResponse ( $ event -> getRequest ( ) , $ exception ) ; break ; case ( $ exception instanceof AccessDeniedHttpException ) : case ( $ exception instanceof UnauthorizedHttpException ) : case ( $ exception instanceof BadRequestHttpException ) : case ( $ exception instanceof ServiceUnavailableHttpException ) : case ( $ exception instanceof NotAcceptableHttpException ) : case ( $ exception instanceof HttpException ) : $ response = $ this -> createHttpExceptionResponse ( $ exception ) ; break ; case ( $ exception instanceof AuthenticationCredentialsNotFoundException ) : $ response = $ this -> createUnauthenticatedResponse ( $ exception ) ; break ; default : } if ( null === $ response ) { $ response = $ this -> createInternalServerError ( $ exception ) ; } $ event -> setResponse ( $ response ) ; } | Maps known exceptions to HTTP exceptions . |
45,294 | private function createNotFoundResponse ( $ request , $ exception ) { $ message = $ exception -> getMessage ( ) ; if ( empty ( $ message ) ) { $ message = 'Uri ' . $ request -> getRequestUri ( ) . ' could not be found' ; } return new JsonResponse ( [ 'status' => 'ERROR' , 'message' => $ message ] , JsonResponse :: HTTP_NOT_FOUND ) ; } | Create a 404 response . |
45,295 | private function createHttpExceptionResponse ( HttpException $ exception ) { return new JsonResponse ( [ 'status' => 'ERROR' , 'message' => $ exception -> getMessage ( ) ] , $ exception -> getStatusCode ( ) , $ exception -> getHeaders ( ) ) ; } | Create a http response . |
45,296 | private function createInternalServerError ( \ Exception $ exception ) { $ message = sprintf ( '%s: %s (uncaught exception) at %s line %s' , get_class ( $ exception ) , $ exception -> getMessage ( ) , $ exception -> getFile ( ) , $ exception -> getLine ( ) ) ; $ this -> logger -> error ( $ message , array ( 'exception' => $ exception ) ) ; $ response = [ 'status' => 'ERROR' , 'message' => JsonResponse :: $ statusTexts [ JsonResponse :: HTTP_INTERNAL_SERVER_ERROR ] ] ; if ( $ this -> debug ) { $ response [ 'exception' ] = $ this -> formatException ( $ exception ) ; } return new JsonResponse ( $ response , JsonResponse :: HTTP_INTERNAL_SERVER_ERROR ) ; } | Create a 500 response . |
45,297 | private function formatStackFrame ( $ frame ) { return [ 'file' => isset ( $ frame [ 'file' ] ) ? $ frame [ 'file' ] : 'unknown' , 'line' => isset ( $ frame [ 'line' ] ) ? $ frame [ 'line' ] : 'unknown' , 'function' => ( isset ( $ frame [ 'class' ] ) ? $ frame [ 'class' ] . $ frame [ 'type' ] : '' ) . $ frame [ 'function' ] , 'arguments' => $ this -> formatArguments ( $ frame [ 'args' ] ) ] ; } | Convert a stack frame to array . |
45,298 | private function formatArguments ( $ arguments ) { $ result = [ ] ; foreach ( $ arguments as $ key => $ argument ) { if ( is_object ( $ argument ) ) { $ result [ $ key ] = get_class ( $ argument ) ; continue ; } if ( is_array ( $ argument ) ) { $ result [ $ key ] = $ this -> formatArguments ( $ argument ) ; continue ; } $ result [ $ key ] = $ argument ; } return $ result ; } | Reformat an argument list . |
45,299 | public static function _init ( ) : Core { static :: $ framework = new Core ( ) ; static :: $ framework -> createDIContainer ( ) ; try { static :: $ framework -> fireEvent ( 'initialized' ) ; } catch ( \ Exception $ e ) { echo ( 'Unable to fire initialization.' ) ; exit ( ) ; } $ router = new Router ( ) ; $ mcl = new ModuleControllerLoader ( ) ; static :: $ framework -> response = new Response ( $ router , $ mcl ) ; return static :: $ framework ; } | Function initializes the framework object . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.