idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
4,000 | protected function parsePlaceholders ( $ pattern ) { $ params = [ ] ; $ parser = $ this -> parser ; preg_match_all ( "~" . $ parser :: DYNAMIC_REGEX . "~x" , $ pattern , $ matches , PREG_SET_ORDER ) ; foreach ( ( array ) $ matches as $ key => $ match ) { $ pattern = str_replace ( $ match [ 0 ] , isset ( $ match [ 2 ] )... | Parse an route pattern seeking for parameters and build the route regex . |
4,001 | protected function parsePath ( $ path ) { $ path = parse_url ( substr ( strstr ( ";" . $ path , ";" . $ this -> basepath ) , strlen ( ";" . $ this -> basepath ) ) , PHP_URL_PATH ) ; if ( $ path === false ) { throw new Exception ( "Seriously malformed URL passed to route matcher." ) ; } return $ path ; } | Get only the path of a given url . |
4,002 | protected function matchSimilarRoute ( $ httpMethod , $ path ) { $ dm = [ ] ; if ( ( $ sm = $ this -> checkStaticRouteInOtherMethods ( $ httpMethod , $ path ) ) || ( $ dm = $ this -> checkDynamicRouteInOtherMethods ( $ httpMethod , $ path ) ) ) { throw new MethodNotAllowedException ( $ httpMethod , $ path , array_merge... | Generate an HTTP error request with method not allowed or not found . |
4,003 | protected function checkStaticRouteInOtherMethods ( $ targetHttpMethod , $ path ) { return array_filter ( $ this -> getHttpMethodsBut ( $ targetHttpMethod ) , function ( $ httpMethod ) use ( $ path ) { return ( bool ) $ this -> collector -> findStaticRoute ( $ httpMethod , $ path ) ; } ) ; } | Verify if a static route match in another method than the requested . |
4,004 | protected function checkDynamicRouteInOtherMethods ( $ targetHttpMethod , $ path ) { return array_filter ( $ this -> getHttpMethodsBut ( $ targetHttpMethod ) , function ( $ httpMethod ) use ( $ path ) { return ( bool ) $ this -> matchDynamicRoute ( $ httpMethod , $ path ) ; } ) ; } | Verify if a dynamic route match in another method than the requested . |
4,005 | public static function fromValue ( $ expected_type , $ actual_value , DeserializationContext $ context = null ) { if ( null !== $ context && count ( $ context -> getCurrentPath ( ) ) > 0 ) { $ property = sprintf ( 'property "%s" to be ' , implode ( '.' , $ context -> getCurrentPath ( ) ) ) ; } else { $ property = '' ; ... | A handy method for building exception instance . |
4,006 | protected function registerAppVersionManager ( ) { $ this -> app -> singleton ( AppVersionManager :: class , function ( Application $ app ) { $ config = ( array ) $ app -> make ( 'config' ) -> get ( static :: getConfigRootKeyName ( ) ) ; return new AppVersionManager ( $ config ) ; } ) ; $ this -> app -> bind ( AppVersi... | Register version manager instance . |
4,007 | protected function initializeConfigs ( ) { $ this -> mergeConfigFrom ( static :: getConfigPath ( ) , static :: getConfigRootKeyName ( ) ) ; $ this -> publishes ( [ realpath ( static :: getConfigPath ( ) ) => config_path ( basename ( static :: getConfigPath ( ) ) ) , ] , 'config' ) ; } | Initialize configs . |
4,008 | protected function compile ( ) { if ( ! $ this -> bootstrap_buttonStyle ) { $ this -> bootstrap_buttonStyle = 'btn-default' ; } $ buttons = Factory :: createFromFieldset ( $ this -> bootstrap_buttons ) ; $ buttons -> eachChild ( array ( $ this , 'addButtonStyle' ) ) ; $ this -> Template -> buttons = $ buttons ; } | Compile the button toolbar . |
4,009 | public function addButtonStyle ( $ child ) { if ( $ child instanceof Group || $ child instanceof Toolbar ) { $ child -> eachChild ( array ( $ this , 'addButtonStyle' ) ) ; } else { $ class = $ child -> getAttribute ( 'class' ) ; $ class = array_filter ( $ class , function ( $ item ) { return strpos ( $ item , 'btn-' ) ... | Add button style . |
4,010 | public function search ( HTTPRequest $ request ) { if ( $ this -> isDisabled ( ) || $ this -> isReadonly ( ) ) { return $ this -> httpError ( 403 ) ; } $ query = $ request -> getVar ( 'query' ) ; if ( $ this -> getSearchCallback ( ) ) { $ results = call_user_func ( $ this -> getSearchCallback ( ) , $ query , $ this ) ;... | The action that handles AJAX search requests |
4,011 | protected function getResults ( $ query ) { $ searchFields = ( $ this -> getSearchFields ( ) ? : singleton ( $ this -> sourceObject ) -> stat ( 'searchable_fields' ) ) ; if ( ! $ searchFields ) { throw new Exception ( sprintf ( 'HasOneAutocompleteField: No searchable fields could be found for class "%s"' , $ this -> so... | Takes the search term and returns a DataList |
4,012 | protected function processResults ( $ results ) { $ json = array ( ) ; foreach ( $ results as $ result ) { $ name = $ result -> { $ this -> labelField } ; $ json [ $ result -> ID ] = array ( 'name' => $ name , 'currentString' => $ this -> getCurrentItemText ( $ result ) ) ; } return $ json ; } | Takes the DataList of search results and returns the json to be sent to the front end . |
4,013 | function getItem ( ) { $ sourceObject = $ this -> sourceObject ; if ( $ this -> value !== null ) { $ item = $ sourceObject :: get ( ) -> byID ( $ this -> value ) ; } else { $ item = $ sourceObject :: create ( ) ; } return $ item ; } | Get the currently selected object |
4,014 | public static function guess ( string $ code ) : string { switch ( strtolower ( trim ( $ code ) ) ) { case SportMapperInterface :: RUNNING : case 'run' : return SportMapperInterface :: RUNNING ; case SportMapperInterface :: CYCLING_SPORT : case 'cycling' : return SportMapperInterface :: CYCLING_SPORT ; case SportMapper... | Get the sport code from the tracker sport code . |
4,015 | public static function bootSluggableTrait ( ) { static :: $ slugsTable = config ( 'pxlcms.slugs.table' , 'cms_slugs' ) ; static :: $ slugsColumn = config ( 'pxlcms.slugs.column' , 'slug' ) ; static :: $ slugsEntryKey = config ( 'pxlcms.slugs.keys.entry' , 'entry_id' ) ; static :: $ slugsModuleKey = config ( 'pxlcms.slu... | Caches config on model boot |
4,016 | public function scopeWhereSlug ( $ scope , $ slug , $ locale = null , $ forHasQuery = false ) { $ model = new static ; if ( $ model -> storeSlugLocally ( ) ) { return $ this -> CviebrockScopeWhereSlug ( $ scope , $ slug ) ; } $ scope = $ scope -> join ( static :: $ slugsTable , function ( $ join ) use ( $ model , $ loc... | Query scope for finding a model by its slug . |
4,017 | protected function setSlug ( $ slug ) { $ config = $ this -> getSluggableConfig ( ) ; $ save_to = $ config [ 'save_to' ] ; if ( $ this -> storeSlugLocally ( ) ) { $ this -> setAttribute ( $ save_to , $ slug ) ; return ; } $ this -> setSlugInCmsTable ( $ slug ) ; } | Set the slug manually . |
4,018 | protected function getSlugRecordFromCmsTable ( ) { $ languageId = $ this -> storeSlugForLanguageId ( ) ; $ entryId = $ this -> isTranslationModel ( ) ? $ this -> getAttribute ( config ( 'pxlcms.translatable.translation_foreign_key' ) ) : $ this -> getKey ( ) ; $ existing = DB :: table ( static :: $ slugsTable ) -> sele... | Returns current slug from CMS slugs table |
4,019 | protected function getAllSlugsForModuleFromCmsTable ( $ likeSlug = null , $ limitToLanguage = true ) { $ config = $ this -> getSluggableConfig ( ) ; $ includeTrashed = $ config [ 'include_trashed' ] ; $ separator = $ config [ 'separator' ] ; $ existing = DB :: table ( static :: $ slugsTable ) -> select ( [ 'id' , stati... | Returns current slugs for this module from CMS slugs table |
4,020 | protected function storeSlugForLanguageId ( ) { $ config = $ this -> getSluggableConfig ( ) ; $ languageKey = array_get ( $ config , 'language_key' ) ; $ localeKey = array_get ( $ config , 'locale_key' ) ; if ( $ languageKey ) { return $ this -> getAttribute ( $ languageKey ) ; } if ( $ localeKey ) { return $ this -> l... | Returns the language_id to store slugs for |
4,021 | protected function flushCache ( Module $ current = null ) { $ message = '' ; if ( $ current === null ) { $ current = Yii :: $ app ; } $ modules = $ current -> getModules ( ) ; foreach ( $ modules as $ moduleName => $ module ) { if ( is_array ( $ module ) ) { $ module = $ current -> getModule ( $ moduleName , true ) ; }... | Recursive flush all app cache |
4,022 | public static function aggregate ( $ array , $ specialKeys = self :: SPECIALS_KEYS , $ prefix = '' ) { $ new = [ ] ; foreach ( $ array as $ key => $ value ) { $ newKey = ( ! empty ( $ prefix ) ) ? $ prefix . '.' . $ key : $ key ; if ( ! in_array ( $ key , $ specialKeys , true ) && ! in_array ( $ key , array_keys ( $ sp... | Aggregate an array to dot notation |
4,023 | public static function disaggregate ( $ array ) { $ new = [ ] ; foreach ( $ array as $ key => $ val ) { if ( false !== strpos ( $ key , "." ) ) { list ( $ realKey , $ aggregated ) = explode ( "." , $ key , 2 ) ; $ values = self :: getDisaggregatedValues ( preg_grep ( "/^$realKey/" , array_keys ( $ array ) ) , $ array )... | Disaggreate a dot notation array to an multi - dimensionnal array |
4,024 | private static function getDisaggregatedValues ( $ keys , $ array ) { $ values = [ ] ; foreach ( $ keys as $ key ) { $ realKey = explode ( "." , $ key , 2 ) [ 1 ] ; $ values [ $ realKey ] = $ array [ $ key ] ; } return $ values ; } | Get values of disaggregated array |
4,025 | public function match ( WURFL_Request_GenericRequest $ request ) { if ( $ this -> canHandle ( $ request -> userAgentNormalized ) ) { return $ this -> applyMatch ( $ request ) ; } if ( isset ( $ this -> nextHandler ) ) { return $ this -> nextHandler -> match ( $ request ) ; } return WURFL_Constants :: GENERIC ; } | Finds the device id for the given request - if it is not found it delegates to the next available handler |
4,026 | public function parseSummaryReport ( ) { $ reports = [ ] ; preg_match_all ( "/^\s*" . "(?<ip>[a-f0-9:\.]+)\s+" . "(?<date>\w+\s+\d+\s\d+)h\/" . "(?<days>\d+)\s+" . "(?<trap>\d+)\s+" . "(?<user>\d+)\s+" . "(?<mole>\d+)\s+" . "(?<simp>\d+)" . "/m" , $ this -> parsedMail -> getMessageBody ( ) , $ matches , PREG_SET_ORDER ... | This is a spamcop formatted summery with a multiple incidents |
4,027 | public function parseAlerts ( ) { $ reports = [ ] ; preg_match_all ( '/\s*(?<ip>[a-f0-9:\.]+)/' , str_replace ( 'IPv6 ' , '' , $ this -> parsedMail -> getMessageBody ( ) ) , $ matches ) ; $ received = $ this -> parsedMail -> getHeaders ( ) [ 'date' ] ; if ( strtotime ( date ( 'd-m-Y H:i:s' , strtotime ( $ received ) ) ... | This is a spamcop formatted alert with a multiple incidents |
4,028 | public function parseSpamReportCustom ( ) { $ reports = [ ] ; $ body = $ this -> parsedMail -> getMessageBody ( ) ; preg_match ( '/(\[ SpamCop V[0-9\.\]\ ]*+)\r?\n(?<message>.*)\r?\n\[ Offending message \]/s' , $ body , $ matches ) ; if ( ! empty ( $ matches [ 'message' ] ) ) { $ report [ 'message' ] = $ matches [ 'mes... | This is a spamcop formatted mail with a single incident |
4,029 | public function parseSpamReportArf ( ) { $ reports = [ ] ; $ this -> arfMail [ 'report' ] = str_replace ( "\r" , "" , $ this -> arfMail [ 'report' ] ) ; preg_match_all ( '/([\w\-]+): (.*)[ ]*\r?\n/' , $ this -> arfMail [ 'report' ] , $ regs ) ; $ report = array_combine ( $ regs [ 1 ] , $ regs [ 2 ] ) ; if ( strpos ( $ ... | This is a ARF mail with a single incident |
4,030 | public function upAction ( Request $ request ) { $ repo = $ this -> get ( 'vince_cms.repository.menu' ) ; $ menu = $ repo -> find ( $ request -> get ( 'id' ) ) ; if ( $ menu -> getParent ( ) ) { $ repo -> moveUp ( $ menu ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'admin_my_cms_menu_list' ) ) ; } | Move menu up |
4,031 | public function downAction ( Request $ request ) { $ repo = $ this -> get ( 'vince_cms.repository.menu' ) ; $ menu = $ repo -> find ( $ request -> get ( 'id' ) ) ; if ( $ menu -> getParent ( ) ) { $ repo -> moveDown ( $ menu ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'admin_my_cms_menu_list' ) ) ; } | Move menu down |
4,032 | public function setIsValid ( $ isValid ) { if ( is_bool ( $ isValid ) ) { $ this -> isValid = $ isValid ; } else { throw new \ InvalidArgumentException ( "Invalid value '" . $ isValid . "' for argument 'isValid' given." ) ; } return $ this ; } | Sets the validation status . |
4,033 | public function addValidationError ( $ errorMessage ) { if ( is_string ( $ errorMessage ) ) { $ this -> validationErrors [ ] = $ errorMessage ; } else { throw new \ InvalidArgumentException ( "Invalid type '" . gettype ( $ errorMessage ) . "' for argument 'errorMessage' given." ) ; } return $ this ; } | Adds a validation error message . |
4,034 | public function filterByDateTime ( $ dateTime = null , $ comparison = null ) { if ( is_array ( $ dateTime ) ) { $ useMinMax = false ; if ( isset ( $ dateTime [ 'min' ] ) ) { $ this -> addUsingAlias ( LogTableMap :: COL_DATE_TIME , $ dateTime [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( ... | Filter the query on the date_time column |
4,035 | public function filterByLogText ( $ logText = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ logText ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ logText ) ) { $ logText = str_replace ( '*' , '%' , $ logText ) ; $ comparison = Criteria :: LIKE ; } } retur... | Filter the query on the log_text column |
4,036 | public function filterBySessionId ( $ sessionId = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ sessionId ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ sessionId ) ) { $ sessionId = str_replace ( '*' , '%' , $ sessionId ) ; $ comparison = Criteria :: LIKE... | Filter the query on the session_id column |
4,037 | public function filterByClientAgent ( $ clientAgent = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ clientAgent ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ clientAgent ) ) { $ clientAgent = str_replace ( '*' , '%' , $ clientAgent ) ; $ comparison = Crit... | Filter the query on the client_agent column |
4,038 | public function filterByClientPlatform ( $ clientPlatform = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ clientPlatform ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ clientPlatform ) ) { $ clientPlatform = str_replace ( '*' , '%' , $ clientPlatform ) ; $... | Filter the query on the client_platform column |
4,039 | public function usage ( $ start = false , $ end = false , $ period = null ) { $ params = array ( ) ; if ( $ start ) { $ params [ 'start' ] = $ start ; } if ( $ end ) { $ params [ 'end' ] = $ end ; } if ( isset ( $ period ) ) { $ params [ 'period' ] = $ period ; } return $ this -> _user -> get ( 'account/usage' , $ para... | Returns the user agent this library should use for all API calls . |
4,040 | public function setDeclarations ( $ declarations ) { $ this -> declarations = [ ] ; if ( ! is_array ( $ declarations ) ) { $ declarations = [ $ declarations ] ; } foreach ( $ declarations as $ declaration ) { $ this -> addDeclaration ( $ declaration ) ; } return $ this ; } | Sets the declarations . |
4,041 | protected function parserHttpHeadersAsArray ( $ rawHeaders ) { $ headers = array ( ) ; foreach ( explode ( "\n" , $ rawHeaders ) as $ i => $ line ) { if ( $ i == 0 ) { $ headers [ 'HTTP_STATUS' ] = substr ( $ line , 9 , 3 ) ; } else { list ( $ key , $ value ) = explode ( ': ' , $ line ) ; $ headers [ trim ( $ key ) ] =... | Convert string headers into an array |
4,042 | public function lock ( ) { if ( $ this -> fp === null ) { $ this -> fp = fopen ( $ this -> file , 'r' ) ; } return flock ( $ this -> fp , LOCK_EX ) ; } | Aquire the mutex |
4,043 | public function unlock ( ) { if ( $ this -> fp !== null ) { flock ( $ this -> fp , LOCK_UN ) ; fclose ( $ this -> fp ) ; $ this -> fp = null ; } return true ; } | Realese the mutex |
4,044 | public static function render ( Query \ Update $ query ) { return Compiler :: withDb ( $ query -> getDb ( ) , function ( ) use ( $ query ) { return Compiler :: expression ( array ( 'UPDATE' , $ query -> getType ( ) , Aliased :: combine ( $ query -> getTable ( ) ) , Join :: combine ( $ query -> getJoin ( ) ) , Compiler ... | Render Update object |
4,045 | public function toString ( ) { $ uses = $ this -> getIterator ( ) ; $ string = '' ; foreach ( $ uses as $ use ) { $ string .= $ use -> toString ( ) ; } return $ string ; } | Parse the Uses to string ; |
4,046 | public static function render ( SQL \ Values $ item ) { $ placeholders = array_fill ( 0 , count ( $ item -> getParameters ( ) ) , '?' ) ; return '(' . join ( ', ' , $ placeholders ) . ')' ; } | Render Values object |
4,047 | protected function autoloadPaths ( $ class ) { $ class = static :: unprefixClass ( $ class ) ; if ( ! in_array ( $ class , array_keys ( $ this -> classMap ) ) ) { return FALSE ; } try { $ resolver = $ this -> tokenResolverFactory -> factory ( $ this -> classMap [ $ class ] ) ; $ finder = $ resolver -> resolve ( ) ; $ f... | Helper function to autoload path based files . |
4,048 | protected function getConfigNameForStandardModelType ( $ type ) { switch ( $ type ) { case CmsModel :: RELATION_TYPE_IMAGE : return 'image' ; case CmsModel :: RELATION_TYPE_FILE : return 'file' ; case CmsModel :: RELATION_TYPE_CATEGORY : return 'category' ; case CmsModel :: RELATION_TYPE_CHECKBOX : return 'checkbox' ; ... | Returns the special model type name used for config properties based on CmsModel const values for RELATION_TYPEs |
4,049 | protected function configure ( array $ config ) { if ( isset ( $ config [ 'parsers' ] ) ) { $ this -> registerParsers ( $ config [ 'parsers' ] ) ; } if ( isset ( $ config [ 'cache' ] ) ) { $ this -> cachePath = rtrim ( 'cache' , '\\/' ) . DIRECTORY_SEPARATOR ; } if ( isset ( $ config [ 'auto_filter' ] ) ) { $ this -> a... | Configures the view manager |
4,050 | public function whitelist ( $ classes ) { if ( ! is_array ( $ classes ) ) { $ classes = func_get_args ( ) ; } $ this -> whitelist = array_unique ( array_merge ( $ this -> whitelist , $ classes ) ) ; } | Adds the given classes to the whitelist . |
4,051 | public function registerParser ( $ extension , Parser $ parser ) { if ( $ parser instanceof ViewManagerAware ) { $ parser -> setViewManager ( $ this ) ; } $ this -> parsers [ $ extension ] = $ parser ; } | Registers a new parser for rendering a given file type |
4,052 | public function registerParsers ( array $ parsers ) { foreach ( $ parsers as $ extension => $ parser ) { $ this -> registerParser ( $ extension , $ parser ) ; } } | Registers multiple parsers at once |
4,053 | public function findView ( $ view ) { $ view = $ this -> viewFolder . DIRECTORY_SEPARATOR . ltrim ( $ view , DIRECTORY_SEPARATOR ) ; return $ this -> finder -> findFileReversed ( $ view ) ; } | Attempts to get the file name for the given view |
4,054 | public function forge ( $ view , array $ data = null , $ filter = null ) { if ( ! $ file = $ this -> findView ( $ view ) ) { throw new Exception \ ViewNotFound ( 'Could not locate view: ' . $ view ) ; } if ( $ filter === null ) { $ filter = $ this -> autoFilter ; } $ extension = pathinfo ( $ file , PATHINFO_EXTENSION )... | Attempts to find and load the given view |
4,055 | public function getCmsReferenceKeyForRelation ( $ relation , $ reversed = false ) { $ isParent = ( array_key_exists ( $ relation , $ this -> relationsConfig ) && array_key_exists ( 'parent' , $ this -> relationsConfig [ $ relation ] ) && ( bool ) $ this -> relationsConfig [ $ relation ] [ 'parent' ] ) ; if ( $ reversed... | Get standard belongsToMany reference key name for from and to models Reversed gives the to key |
4,056 | public function getCmsReferenceFieldId ( $ relation ) { if ( ! array_key_exists ( $ relation , $ this -> relationsConfig ) || ! array_key_exists ( 'field' , $ this -> relationsConfig [ $ relation ] ) ) { return null ; } return ( int ) $ this -> relationsConfig [ $ relation ] [ 'field' ] ; } | Returns the configured from_field_id field id value for the reference relation |
4,057 | public function getCmsSpecialRelationType ( $ relation ) { if ( ! array_key_exists ( $ relation , $ this -> relationsConfig ) || ! array_key_exists ( 'type' , $ this -> relationsConfig [ $ relation ] ) ) { return null ; } return $ this -> relationsConfig [ $ relation ] [ 'type' ] ; } | Returns the configured special standard model type for the reference relation |
4,058 | public function belongsTo ( $ related , $ foreignKey = null , $ otherKey = null , $ relation = null ) { if ( is_null ( $ relation ) ) { list ( $ current , $ caller ) = debug_backtrace ( false , 2 ) ; $ relation = $ caller [ 'function' ] ; } $ specialType = $ this -> getCmsSpecialRelationType ( $ relation ) ; if ( is_nu... | Override for different naming convention |
4,059 | public function belongsToMany ( $ related , $ table = null , $ foreignKey = null , $ otherKey = null , $ relation = null ) { if ( is_null ( $ relation ) ) { $ relation = $ this -> getBelongsToManyCaller ( ) ; } $ foreignKey = $ foreignKey ? : $ this -> getCmsReferenceKeyForRelation ( $ relation ) ; $ otherKey = $ other... | Override for special cms_m_references pivot table |
4,060 | public function belongsToManyNormal ( $ related , $ table = null , $ foreignKey = null , $ otherKey = null , $ relation = null ) { return parent :: belongsToMany ( $ related , $ table , $ foreignKey , $ otherKey , $ relation ) ; } | For when you still want to use the normal belongsToMany relationship in a CmsModel that should be related to non - CmsModels in the laravel convention |
4,061 | public function hasOne ( $ related , $ foreignKey = null , $ localKey = null , $ locale = null ) { $ relation = $ this -> getHasOneOrManyCaller ( ) ; if ( ! ( $ specialType = $ this -> getCmsSpecialRelationType ( $ relation ) ) ) { return parent :: hasOne ( $ related , $ foreignKey , $ localKey ) ; } list ( $ foreignKe... | Overridden to catch special relationships to standard CMS models |
4,062 | protected function getKeysForSpecialRelation ( $ specialType , $ foreignKey = null ) { switch ( $ specialType ) { case static :: RELATION_TYPE_FILE : $ foreignKey = $ foreignKey ? : config ( 'pxlcms.relations.files.keys.entry' ) ; $ secondaryKey = config ( 'pxlcms.relations.files.keys.field' ) ; break ; case static :: ... | Get the foreign and field keys for the special relation s standard CMS model |
4,063 | public function getBelongsToRelationAttributeValue ( $ key ) { $ relationKey = camel_case ( $ key ) ; $ attributeKey = snake_case ( $ key ) ; if ( $ this -> relationLoaded ( $ relationKey ) ) { $ self = __FUNCTION__ ; $ caller = array_first ( debug_backtrace ( false ) , function ( $ key , $ trace ) use ( $ self ) { $ c... | Returns value for either foreign key or eager loaded contents of relation depending on what is expected |
4,064 | protected function getImagesWithResizes ( ) { $ relation = $ this -> getRelationForImagesWithResizesCaller ( ) ; $ images = $ this -> { $ relation } ( ) -> get ( ) ; if ( empty ( $ images ) ) return $ images ; $ fieldId = $ this -> getCmsReferenceFieldId ( $ relation ) ; $ resizes = $ this -> getResizesForFieldId ( $ f... | Returns resize - enriched images for a special CMS model image relation |
4,065 | protected function getRelationForImagesWithResizesCaller ( ) { $ self = __FUNCTION__ ; $ caller = Arr :: first ( debug_backtrace ( false ) , function ( $ key , $ trace ) use ( $ self ) { $ caller = $ trace [ 'function' ] ; return ! in_array ( $ caller , [ 'getImagesWithResizes' ] ) && $ caller != $ self ; } ) ; if ( is... | Get the relationship name of the image accessor for which images are enriched |
4,066 | public function lookupLocaleForLanguageId ( $ languageId ) { $ languageModel = static :: $ cmsLanguageModel ; $ language = $ languageModel :: where ( 'id' , $ languageId ) -> remember ( ( config ( 'pxlcms.cache.languages' , 15 ) ) ) -> first ( ) ; if ( empty ( $ language ) ) return null ; return $ this -> normalizeToLo... | Retrieves locale for a given language ID code |
4,067 | public function execute ( $ sql , array $ parameters = array ( ) ) { $ this -> logger -> info ( $ sql , array ( 'parameters' => $ parameters ) ) ; try { $ statement = $ this -> getPdo ( ) -> prepare ( $ sql ) ; $ statement -> execute ( $ parameters ) ; } catch ( PDOException $ exception ) { $ this -> logger -> error ( ... | Run prepare a statement and then execute it |
4,068 | private function addShippingOptions ( Order $ order , FormInterface $ form ) { if ( $ order -> getShippingMethod ( ) instanceof ShippingMethod ) { $ provider = $ this -> getOptionsProvider ( $ order -> getShippingMethod ( ) ) ; if ( $ provider instanceof ShippingMethodOptionsProviderInterface ) { $ form -> addChild ( $... | Adds shipping options if available for order s shipping method |
4,069 | public function parse ( array $ input ) { $ this -> data = Arr :: get ( $ input , 'data' ) ; if ( $ this -> data === null ) { return null ; } $ this -> included = Arr :: get ( $ input , 'included' , [ ] ) ; $ this -> start ( ) ; return $ this -> resolver -> getResolved ( ) ; } | Parse the data given |
4,070 | public function resolver ( $ resourceNames , $ callback ) { $ resourceNames = Arr :: wrap ( $ resourceNames ) ; foreach ( $ resourceNames as $ name ) { $ this -> resolver -> bind ( $ name , $ callback ) ; } return $ this ; } | Adds the callbacks for resolve the different objects in the response |
4,071 | public function fetcher ( $ className , $ relationshipName , $ callback = null ) { $ this -> resolver -> bindFetcher ( $ className , $ relationshipName , $ callback ) ; return $ this ; } | Add a callback for a class that when called will return an existing instance of a relationship . |
4,072 | private function start ( ) { if ( Arr :: is_assoc ( $ this -> data ) ) { $ this -> data = [ $ this -> data ] ; } foreach ( $ this -> data as $ data ) { $ relationshipsToProcess = $ this -> resolveResource ( $ data ) ; $ this -> resolveRelationships ( $ relationshipsToProcess ) ; } } | Starts the parsing and creating of the relationships . |
4,073 | private function getIncludedResource ( $ id , $ type ) { foreach ( $ this -> included as $ included ) { $ includedId = Arr :: get ( $ included , 'id' ) ; $ includedType = Arr :: get ( $ included , 'type' ) ; if ( ( string ) $ includedType === ( string ) $ type && ( string ) $ includedId === ( string ) $ id ) { return $... | Get a resource that is in the included array |
4,074 | public function get ( $ code = null ) : string { if ( ! $ this -> validate ( $ code ) ) { throw new \ InvalidArgumentException ( 'Invalid code' ) ; } return isset ( self :: $ codes [ $ code ] ) ? self :: $ codes [ $ code ] : '' ; } | Get local name by code |
4,075 | public function getCity ( $ code ) : string { $ provinceCode = substr ( $ code , 0 , 2 ) . '0000' ; $ cityCode = substr ( $ code , 0 , 4 ) . '00' ; if ( $ provinceCode != $ cityCode ) { return $ this -> get ( $ cityCode ) ; } return '' ; } | Get the city by code |
4,076 | public function getAddress ( $ code ) : string { return $ this -> getProvince ( $ code ) . $ this -> getCity ( $ code ) . $ this -> getCounty ( $ code ) ; } | Get the address by code |
4,077 | public function search ( $ query , $ page = 1 ) { return $ this -> get ( sprintf ( 'files/search/%s/page/%d' , rawurlencode ( trim ( $ query ) ) , $ page ) ) ; } | Returns an array of files matching the given search query . |
4,078 | public function upload ( $ file , $ parentID = 0 ) { if ( ! $ file = realpath ( $ file ) ) { throw new \ Exception ( 'File not found' ) ; } return $ this -> uploadFile ( 'files/upload' , [ 'parent_id' => $ parentID , 'file' => "@{$file}" ] ) ; } | Uploads a local file to your account . |
4,079 | public function makeDir ( $ name , $ parentID = 0 ) { $ data = [ 'name' => $ name , 'parent_id' => $ parentID ] ; return $ this -> post ( 'files/create-folder' , $ data , \ false , 'file' ) ; } | Creates a new folder . Returns folder info on success false on error . |
4,080 | public function delete ( $ fileIDs ) { if ( is_array ( $ fileIDs ) ) { $ fileIDs = implode ( ',' , $ fileIDs ) ; } $ data = [ 'file_ids' => $ fileIDs ] ; return $ this -> post ( 'files/delete' , $ data , \ true ) ; } | Deletes files from your account . |
4,081 | public function move ( $ fileIDs , $ parentID ) { if ( is_array ( $ fileIDs ) ) { $ fileIDs = implode ( ',' , $ fileIDs ) ; } $ data = [ 'file_ids' => $ fileIDs , 'parent_id' => $ parentID ] ; return $ this -> post ( 'files/move' , $ data , \ true ) ; } | Moves one of more files to a new directory . |
4,082 | private function deletePreset ( $ imagePath ) { $ finalPath = ROOT_PATH . $ this -> url . DIRECTORY_SEPARATOR . $ imagePath ; if ( file_exists ( $ finalPath ) ) { unlink ( $ finalPath ) ; } } | Delete a preset of an image |
4,083 | public static function createPresets ( $ path = null , $ callback = null ) { $ moufManager = MoufManager :: getMoufManager ( ) ; $ instances = $ moufManager -> findInstances ( 'Mouf\\Utils\\Graphics\\MoufImagine\\Controller\\ImagePresetController' ) ; foreach ( $ instances as $ instanceName ) { $ instance = $ moufManag... | Create presets of an image |
4,084 | public static function purgePresets ( $ path = null , $ callback = null ) { $ moufManager = MoufManager :: getMoufManager ( ) ; $ instances = $ moufManager -> findInstances ( 'Mouf\\Utils\\Graphics\\MoufImagine\\Controller\\ImagePresetController' ) ; foreach ( $ instances as $ instanceName ) { $ instance = $ moufManage... | Purge presets of an image |
4,085 | public function registerClientScript ( ) { $ view = $ this -> getView ( ) ; TwbsMaxlengthAsset :: register ( $ view ) ; $ options = empty ( $ this -> clientOptions ) ? "{}" : Json :: encode ( $ this -> clientOptions ) ; if ( isset ( $ this -> selector ) ) { $ js = "jQuery(\"{$this->selector}\").maxlength(" . $ options ... | Generates and registers javascript to start the plugin . |
4,086 | public static function apply ( $ field , $ clientOptions , $ render = true ) { if ( isset ( $ field -> inputOptions [ 'maxlength' ] ) ) { $ maxLength = $ field -> inputOptions [ 'maxlength' ] ; } else { $ maxLength = static :: getMaxLength ( $ field -> model , Html :: getAttributeName ( $ field -> attribute ) ) ; } if ... | Add the maxlength attribute to an ActiveField . |
4,087 | public static function getMaxLength ( $ model , $ attribute , $ defaultValue = null ) { $ maxLength = null ; foreach ( $ model -> getActiveValidators ( $ attribute ) as $ validator ) { if ( $ validator instanceof yii \ validators \ StringValidator ) { $ maxLength = $ validator -> max ; break ; } } return $ maxLength !=... | Find the maxlength parameter for an attribute s model . |
4,088 | public function getEntityTypeManager ( ) { if ( empty ( $ this -> entityTypeManager ) ) { $ this -> entityTypeManager = \ Drupal :: entityTypeManager ( ) ; } return $ this -> entityTypeManager ; } | Gets the entity type manager . |
4,089 | public static function parse ( $ value , $ default = null ) { if ( ! is_string ( $ value ) || ! is_numeric ( $ value ) ) { return $ default ; } if ( Int :: extIs ( $ value ) ) { return Int :: parse ( $ value ) ; } else { return Float :: parse ( $ value ) ; } } | Parses a string numeric value into an integer or a float . |
4,090 | public static function compare ( $ num1 , $ num2 ) { if ( ! static :: is ( $ num1 ) || ! static :: is ( $ num2 ) ) { throw new \ InvalidArgumentException ( "The \$num1 and \$num2 parameters must be numeric." ) ; } return ( $ num1 - $ num2 ) ; } | Compares two numeric values . |
4,091 | final public function output ( $ atts , $ content = null , $ tag = null ) { if ( empty ( $ tag ) ) { $ tag = $ this -> get_tag ( ) ; } $ output = $ this -> render ( $ atts , $ content , $ tag ) ; return \ apply_filters ( 'syllables/shortcode/output' , $ output , $ atts , $ content , $ tag ) ; } | Callback that outputs the shortcode . |
4,092 | public function render ( $ atts , $ content = null , $ tag = null ) { if ( is_callable ( $ this -> callback ) ) { $ content = call_user_func ( $ this -> callback , $ atts , $ content , $ tag ) ; } return \ apply_filters ( 'syllables/shortcode/render' , $ content , $ atts , $ tag ) ; } | Renders the hooked shortcode . |
4,093 | public function generate ( ) { return sprintf ( '<%s %s>%s</%s>%s' , $ this -> tag , parent :: generate ( ) , $ this -> label , $ this -> tag , PHP_EOL ) ; } | Generate the button . |
4,094 | public function handle ( InitMessage $ message ) { $ output = $ message -> getOutput ( ) ; $ configStorage = $ message -> getConfigStorage ( ) ; if ( $ configStorage -> isInitialized ( $ message -> getConfig ( ) ) ) { $ output -> writeln ( sprintf ( '%s is already initialised!' , $ message -> getCliCommand ( ) -> getAp... | Handle an InitMessage . Creates an end - user configuration file using default values . If the file already exists it simply exists without doing anything . |
4,095 | private function setIcon ( ) { if ( ! $ this -> slackConfig -> getCustomUser ( ) -> hasIcon ( ) ) { return ; } $ iconType = 'icon_' . $ this -> slackConfig -> getCustomUser ( ) -> getIcon ( ) -> getType ( ) ; $ this -> payload [ $ iconType ] = $ this -> slackConfig -> getCustomUser ( ) -> getIcon ( ) ; } | Set a custom icon if available . |
4,096 | private function setUsername ( ) { if ( ! $ this -> slackConfig -> getCustomUser ( ) -> hasUsername ( ) ) { return ; } $ this -> payload [ 'username' ] = $ this -> slackConfig -> getCustomUser ( ) -> getUsername ( ) ; } | Set a custom username if available . |
4,097 | private function setChannel ( ) { if ( ! $ this -> slackConfig -> getWebhook ( ) -> hasCustomChannel ( ) ) { return ; } $ this -> payload [ 'channel' ] = $ this -> slackConfig -> getWebhook ( ) -> getCustomChannel ( ) ; } | Set a custom channel if available . |
4,098 | private function setErrorData ( ) { if ( ! isset ( $ this -> record [ 'context' ] [ 'error' ] ) ) { return ; } $ this -> errorData = $ this -> record [ 'context' ] [ 'error' ] ; unset ( $ this -> record [ 'context' ] [ 'error' ] ) ; } | If available set the error data . |
4,099 | private function shouldIgnoreUse ( PHP_CodeSniffer_File $ file , $ position ) : bool { $ tokens = $ file -> getTokens ( ) ; $ next = $ file -> findNext ( T_WHITESPACE , ( $ position + 1 ) , NULL , TRUE ) ; if ( $ tokens [ $ next ] [ 'code' ] === T_OPEN_PARENTHESIS ) { return TRUE ; } if ( $ file -> hasCondition ( $ pos... | Check if this use statement is part of the namespace block . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.