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 ] ) ? "({$match[2]})" : "([^/]+)" , $ pattern ) ; $ params [ $ key ] = $ match [ 1 ] ; } return [ $ pattern , $ params ] ; }
|
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 ( ( array ) $ sm , ( array ) $ dm ) ) ; } throw new NotFoundException ; }
|
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 = '' ; } return new static ( sprintf ( 'Expected %s%s, but got %s: %s' , $ property , $ expected_type , gettype ( $ actual_value ) , json_encode ( $ actual_value ) ) ) ; }
|
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 ( AppVersionManagerContract :: class , AppVersionManager :: class ) ; $ this -> app -> bind ( static :: VERSION_MANAGER_ALIAS , AppVersionManagerContract :: class ) ; }
|
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-' ) !== false ; } ) ; if ( ! $ class && $ this -> bootstrap_buttonStyle ) { $ child -> addClass ( $ this -> bootstrap_buttonStyle ) ; } } }
|
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 ) ; } else { $ results = $ this -> getResults ( $ query ) ; } if ( $ this -> getProcessCallback ( ) ) { $ json = call_user_func ( $ this -> getProcessCallback ( ) , $ results , $ this ) ; } else { $ json = $ this -> processResults ( $ results ) ; } return Convert :: array2json ( $ json ) ; }
|
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 -> sourceObject ) ) ; } $ params = [ ] ; $ sort = [ ] ; foreach ( $ searchFields as $ searchField ) { $ name = ( strpos ( $ searchField , ':' ) !== FALSE ) ? $ searchField : "$searchField:PartialMatch:nocase" ; $ params [ $ name ] = $ query ; $ sort [ $ searchField ] = "ASC" ; } $ results = DataList :: create ( $ this -> sourceObject ) -> filterAny ( $ params ) -> sort ( $ sort ) -> limit ( $ this -> getResultsLimit ( ) ) ; return $ results ; }
|
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 SportMapperInterface :: CYCLING_TRANSPORT : return SportMapperInterface :: CYCLING_TRANSPORT ; case SportMapperInterface :: SWIMMING : return SportMapperInterface :: SWIMMING ; default : return SportMapperInterface :: OTHER ; } }
|
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.slugs.keys.module' , 'module_id' ) ; static :: $ slugsLanguageKey = config ( 'pxlcms.slugs.keys.language' , 'language_id' ) ; static :: $ slugsActiveColumn = config ( 'pxlcms.slugs.active_column' , false ) ; }
|
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 , $ locale ) { $ idKey = $ this -> isTranslationModel ( ) ? config ( 'pxlcms.translatable.translation_foreign_key' ) : $ this -> getKeyName ( ) ; $ join -> on ( $ model -> getTable ( ) . '.' . $ idKey , '=' , static :: $ slugsTable . '.' . static :: $ slugsEntryKey ) ; $ join -> on ( static :: $ slugsTable . '.' . static :: $ slugsModuleKey , '=' , DB :: raw ( ( int ) $ model -> getModuleNumber ( ) ) ) ; if ( ! empty ( $ locale ) && $ model -> isTranslationModel ( ) ) { $ languageId = $ model -> lookUpLanguageIdForLocale ( $ locale ) ; $ join -> on ( static :: $ slugsTable . '.' . static :: $ slugsLanguageKey , '=' , DB :: raw ( ( int ) $ languageId ) ) ; } } ) ; return $ scope -> where ( static :: $ slugsTable . '.' . static :: $ slugsColumn , $ slug ) -> select ( $ this -> getTable ( ) . '.' . ( $ forHasQuery ? 'id' : '*' ) ) ; }
|
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 ) -> select ( [ 'id' , static :: $ slugsColumn . ' as slug' ] ) -> where ( static :: $ slugsModuleKey , $ this -> getModuleNumber ( ) ) -> where ( static :: $ slugsEntryKey , $ entryId ) ; if ( is_null ( $ languageId ) ) { $ existing = $ existing -> where ( function ( $ query ) { return $ query -> whereNull ( static :: $ slugsLanguageKey ) -> orWhere ( static :: $ slugsLanguageKey , 0 ) -> orWhere ( static :: $ slugsLanguageKey , '' ) ; } ) ; } else { $ existing = $ existing -> where ( static :: $ slugsLanguageKey , $ languageId ) ; } $ existing = $ existing -> limit ( 1 ) -> first ( ) ; if ( empty ( $ existing ) ) return null ; return $ existing ; }
|
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' , static :: $ slugsColumn . ' as slug' ] ) -> where ( static :: $ slugsModuleKey , $ this -> getModuleNumber ( ) ) -> where ( function ( $ query ) use ( $ likeSlug , $ separator ) { $ query -> where ( static :: $ slugsColumn , $ likeSlug ) ; $ query -> orWhere ( static :: $ slugsColumn , 'LIKE' , $ likeSlug . $ separator . '%' ) ; } ) ; if ( ! $ includeTrashed && static :: $ slugsActiveColumn ) { $ existing -> where ( static :: $ slugsActiveColumn , true ) ; } if ( $ limitToLanguage ) { $ existing -> where ( static :: $ slugsLanguageKey , $ this -> storeSlugForLanguageId ( ) ) ; } $ list = $ existing -> lists ( static :: $ slugsColumn , static :: $ slugsEntryKey ) ; return $ list instanceof Collection ? $ list -> all ( ) : $ list ; }
|
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 -> lookupLanguageIdForLocale ( $ this -> getAttribute ( $ localeKey ) ) ; } return null ; }
|
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 ) ; } if ( $ module instanceof Module ) { $ message .= $ this -> flushCache ( $ module ) ; } } $ components = $ current -> getComponents ( ) ; foreach ( $ components as $ componentName => $ component ) { if ( is_array ( $ component ) && $ componentName != 'user' ) { $ component = $ current -> get ( $ componentName ) ; } if ( $ component instanceof Cache ) { $ message .= $ component -> flush ( ) ? '<p>' . Yii :: t ( 'wocenter/app' , '{currentModuleName}: {componentName} is flushed.' , [ 'currentModuleName' => $ current -> className ( ) , 'componentName' => $ component -> className ( ) , ] ) . '</p>' : '' ; } } return $ message ; }
|
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 ( $ specialKeys ) , true ) ) { if ( is_a ( $ value , "stdClass" ) ) { $ value = ( array ) $ value ; } if ( is_array ( $ value ) ) { $ new += self :: aggregate ( $ value , $ specialKeys , $ newKey ) ; } else { $ new [ $ newKey ] = $ value ; } } else { if ( array_key_exists ( $ key , $ specialKeys ) && is_callable ( $ specialKeys [ $ key ] ) ) { $ new = call_user_func ( $ specialKeys [ $ key ] , $ prefix , $ key , $ value , $ new ) ; } } } return $ new ; }
|
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 ) ; $ new [ $ realKey ] = self :: disaggregate ( $ values ) ; } else { $ new [ $ key ] = $ val ; } } return $ new ; }
|
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 ) ; if ( is_array ( $ matches ) && count ( $ matches ) > 0 ) { foreach ( $ matches as $ match ) { $ report = [ 'Source-IP' => $ match [ 'ip' ] , 'Received-Date' => $ match [ 'date' ] . ':00' , 'Duration-Days' => $ match [ 'days' ] , ] ; foreach ( [ 'trap' , 'user' , 'mole' , 'simp' ] as $ field ) { $ report [ ucfirst ( $ field ) . "-Report" ] = $ match [ $ field ] ; } $ reports [ ] = $ report ; } } return $ reports ; }
|
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 ) ) ) !== ( int ) strtotime ( $ received ) ) { $ received = date ( 'd-m-Y H:i:s' ) ; } if ( is_array ( $ matches ) && ! empty ( $ matches [ 'ip' ] ) && count ( $ matches [ 'ip' ] ) > 0 ) { foreach ( $ matches [ 'ip' ] as $ ip ) { $ reports [ ] = [ 'Source-IP' => $ ip , 'Received-Date' => $ received , 'Note' => 'A spamtrap hit notification was received.' . ' These notifications do not provide any evidence.' ] ; } } return $ reports ; }
|
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 [ 'message' ] ; } preg_match ( '/(\[ Offending message \]*+)\r?\n(?<evidence>.*)/s' , $ body , $ matches ) ; if ( ! empty ( $ matches [ 'evidence' ] ) ) { $ parsedEvidence = new MimeParser ( ) ; $ parsedEvidence -> setText ( $ matches [ 'evidence' ] ) ; $ report [ 'evidence' ] = $ parsedEvidence -> getHeaders ( ) ; } if ( ! empty ( $ report [ 'message' ] ) && ! empty ( $ report [ 'evidence' ] ) ) { preg_match ( '/Email from (?<ip>[a-f0-9:\.]+) \/ (?<date>.*)/' , $ report [ 'message' ] , $ matches ) ; if ( ! empty ( $ matches [ 'ip' ] ) && ! empty ( $ matches [ 'date' ] ) ) { $ report [ 'Source-IP' ] = $ matches [ 'ip' ] ; $ report [ 'Received-Date' ] = $ matches [ 'date' ] ; $ reports [ ] = $ report ; } $ report [ 'message' ] = str_replace ( '\r' , '' , $ report [ 'message' ] ) ; preg_match ( '/Spamvertised web site:\s' . '(?<url>.*)\\n' . '(?<reply>.*)\n' . '(?<resolved>.*) is (?<ip>.*); (?<date>.*)\n' . '/' , $ report [ 'message' ] , $ matches ) ; if ( ! empty ( $ matches [ 'ip' ] ) && ! empty ( $ matches [ 'date' ] ) && ! empty ( $ matches [ 'url' ] ) ) { $ report [ 'Source-IP' ] = $ matches [ 'ip' ] ; $ report [ 'Received-Date' ] = $ matches [ 'date' ] ; $ report [ 'Report-URL' ] = $ matches [ 'reply' ] ; $ report [ 'Spam-URL' ] = $ matches [ 'url' ] ; $ reports [ ] = $ report ; } } else { $ this -> warningCount ++ ; } return $ reports ; }
|
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 -> arfMail [ 'message' ] , 'Comments from recipient' ) !== false ) { preg_match ( "/Comments from recipient.*\s]\n(.*)\n\n\nThis/s" , str_replace ( array ( "\r" , "> " ) , "" , $ this -> arfMail [ 'message' ] ) , $ match ) ; $ report [ 'recipient_comment' ] = str_replace ( "\n" , " " , $ match [ 1 ] ) ; } $ parsedEvidence = new MimeParser ( ) ; $ parsedEvidence -> setText ( $ this -> arfMail [ 'evidence' ] ) ; $ headers = $ parsedEvidence -> getHeaders ( ) ; foreach ( $ headers as $ key => $ value ) { if ( is_array ( $ value ) || is_object ( ( $ value ) ) ) { foreach ( $ value as $ index => $ subvalue ) { $ report [ 'headers' ] [ "${key}${index}" ] = "$subvalue" ; } } else { $ report [ 'headers' ] [ "$key" ] = $ value ; } } if ( empty ( $ report [ 'Source-IP' ] ) ) { preg_match ( "/Email from (?<ip>[a-f0-9:\.]+) \/ " . preg_quote ( $ report [ 'Received-Date' ] ) . "/s" , $ this -> arfMail [ 'message' ] , $ regs ) ; if ( ! empty ( $ regs [ 'ip' ] ) && ! filter_var ( $ regs [ 'ip' ] , FILTER_VALIDATE_IP ) === false ) { $ report [ 'Source-IP' ] = $ regs [ 'ip' ] ; } preg_match ( "/from: (?<ip>[a-f0-9:\.]+)\r?\n?\r\n/s" , $ this -> parsedMail -> getMessageBody ( ) , $ regs ) ; if ( ! empty ( $ regs [ 'ip' ] ) && ! filter_var ( $ regs [ 'ip' ] , FILTER_VALIDATE_IP ) === false ) { $ report [ 'Source-IP' ] = $ regs [ 'ip' ] ; } } $ reports [ ] = $ report ; return $ reports ; }
|
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 ( $ dateTime [ 'max' ] ) ) { $ this -> addUsingAlias ( LogTableMap :: COL_DATE_TIME , $ dateTime [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( LogTableMap :: COL_DATE_TIME , $ dateTime , $ comparison ) ; }
|
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 ; } } return $ this -> addUsingAlias ( LogTableMap :: COL_LOG_TEXT , $ logText , $ comparison ) ; }
|
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 ; } } return $ this -> addUsingAlias ( LogTableMap :: COL_SESSION_ID , $ sessionId , $ comparison ) ; }
|
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 = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( LogTableMap :: COL_CLIENT_AGENT , $ clientAgent , $ comparison ) ; }
|
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 ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( LogTableMap :: COL_CLIENT_PLATFORM , $ clientPlatform , $ comparison ) ; }
|
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' , $ params ) ; }
|
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 ) ] = trim ( $ value ) ; } } return $ headers ; }
|
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 :: word ( 'SET' , Set :: combine ( $ query -> getSet ( ) ) ) , Compiler :: word ( 'WHERE' , Condition :: combine ( $ query -> getWhere ( ) ) ) , Compiler :: word ( 'ORDER BY' , Direction :: combine ( $ query -> getOrder ( ) ) ) , Compiler :: word ( 'LIMIT' , $ query -> getLimit ( ) ) , ) ) ; } ) ; }
|
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 ( ) ; $ finder -> requireFile ( $ this -> seed ) ; return TRUE ; } catch ( ClassLoaderException $ e ) { return FALSE ; } }
|
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' ; } return null ; }
|
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 -> autoFilter = ( bool ) $ config [ 'auto_filter' ] ; } if ( isset ( $ config [ 'view_folder' ] ) ) { $ this -> setViewFolder ( $ config [ 'view_folder' ] ) ; } if ( isset ( $ config [ 'whitelist' ] ) ) { $ this -> whitelist ( $ config [ 'whitelist' ] ) ; } }
|
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 ) ; if ( ! isset ( $ this -> parsers [ $ extension ] ) ) { throw new \ DomainException ( 'Could not find parser for extension: ' . $ extension ) ; } $ parser = $ this -> parsers [ $ extension ] ; $ view = new View ( $ this , $ parser , $ file , $ filter ) ; if ( $ data ) { $ view -> set ( $ data ) ; } return $ view ; }
|
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 ) { $ isParent = ! $ isParent ; } return $ isParent ? config ( 'pxlcms.relations.references.keys.to' , 'to_entry_id' ) : config ( 'pxlcms.relations.references.keys.from' , 'from_entry_id' ) ; }
|
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_null ( $ foreignKey ) ) { if ( $ specialType === self :: RELATION_TYPE_CATEGORY ) { $ foreignKey = config ( 'pxlcms.relations.categories.keys.category' ) ; } else { $ foreignKey = Str :: snake ( $ relation ) ; } } if ( snake_case ( $ relation ) == $ foreignKey && ! array_key_exists ( $ foreignKey , $ this -> attributes ) ) { $ this -> attributes [ $ foreignKey ] = null ; } $ belongsTo = parent :: belongsTo ( $ related , $ foreignKey , $ otherKey , $ relation ) ; if ( $ specialType === self :: RELATION_TYPE_CATEGORY ) { $ belongsTo -> where ( config ( 'pxlcms.relations.categories.keys.module' ) , $ this -> getModuleNumber ( ) ) ; } return $ belongsTo ; }
|
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 = $ otherKey ? : $ this -> getCmsReferenceKeyForRelation ( $ relation , true ) ; if ( is_null ( $ table ) ) { $ table = $ this -> getCmsJoiningTable ( ) ; } $ fieldId = $ this -> getCmsReferenceFieldId ( $ relation ) ; if ( empty ( $ fieldId ) ) { throw new InvalidArgumentException ( "No 'field' id configured for relation/reference: '{$relation}'!" ) ; } $ instance = new $ related ; $ query = $ instance -> newQuery ( ) ; $ belongsToMany = new BelongsToMany ( $ query , $ this , $ table , $ foreignKey , $ otherKey , $ relation , $ fieldId ) ; $ belongsToMany -> wherePivot ( config ( 'pxlcms.relations.references.keys.field' , 'from_field_id' ) , $ fieldId ) ; return $ belongsToMany ; }
|
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 ( $ foreignKey , $ fieldKey ) = $ this -> getKeysForSpecialRelation ( $ specialType , $ foreignKey ) ; $ fieldId = $ this -> getCmsReferenceFieldId ( $ relation ) ; if ( $ specialType === static :: RELATION_TYPE_CHECKBOX || $ specialType === static :: RELATION_TYPE_FILE || $ specialType === static :: RELATION_TYPE_IMAGE ) { $ instance = new $ related ; $ localKey = $ localKey ? : $ this -> getKeyName ( ) ; $ hasOne = new HasOne ( $ instance -> newQuery ( ) , $ this , $ instance -> getTable ( ) . '.' . $ foreignKey , $ localKey , $ fieldId , $ specialType ) ; } else { $ hasOne = parent :: hasOne ( $ related , $ foreignKey , $ localKey ) ; } $ hasOne -> where ( $ fieldKey , $ fieldId ) ; if ( $ this -> getCmsSpecialRelationTranslated ( $ relation ) ) { if ( is_null ( $ locale ) ) $ locale = app ( ) -> getLocale ( ) ; $ hasOne -> where ( config ( 'pxlcms.translatable.locale_key' ) , $ this -> lookUpLanguageIdForLocale ( $ locale ) ) ; } return $ hasOne ; }
|
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 :: RELATION_TYPE_CHECKBOX : $ foreignKey = $ foreignKey ? : config ( 'pxlcms.relations.checkboxes.keys.entry' ) ; $ secondaryKey = config ( 'pxlcms.relations.checkboxes.keys.field' ) ; break ; case static :: RELATION_TYPE_IMAGE : default : $ foreignKey = $ foreignKey ? : config ( 'pxlcms.relations.images.keys.entry' ) ; $ secondaryKey = config ( 'pxlcms.relations.images.keys.field' ) ; } return [ $ foreignKey , $ secondaryKey ] ; }
|
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 ) { $ caller = $ trace [ 'function' ] ; if ( $ key < 2 ) { return false ; } if ( array_get ( $ trace , 'class' ) === 'Illuminate\Database\Eloquent\Relations\BelongsTo' ) { return false ; } return $ caller != $ self && $ caller != 'mutateAttribute' && $ caller != 'getAttributeValue' && $ caller != 'getAttribute' && $ caller != '__get' ; } ) ; if ( ! array_key_exists ( 'class' , $ caller ) || ( $ caller [ 'class' ] !== 'Illuminate\Database\Eloquent\Model' && $ caller [ 'class' ] !== 'Illuminate\Database\Eloquent\Builder' && $ caller [ 'class' ] !== 'Illuminate\Database\Eloquent\Relations\Relation' ) ) { return $ this -> relations [ $ relationKey ] ; } } return $ this -> attributes [ $ attributeKey ] ; }
|
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 ( $ fieldId ) ; if ( empty ( $ resizes ) ) return $ images ; foreach ( $ images as $ image ) { $ fileName = $ image -> file ; $ imageResizes = [ ] ; foreach ( $ resizes as $ resize ) { $ imageResizes [ $ resize -> prefix ] = [ 'id' => $ resize -> id , 'prefix' => $ resize -> prefix , 'file' => $ resize -> prefix . $ fileName , 'url' => Paths :: images ( $ resize -> prefix . $ fileName ) , 'width' => $ resize -> width , 'height' => $ resize -> height , ] ; } $ image -> resizes = $ imageResizes ; } return $ images ; }
|
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_null ( $ caller ) ) return null ; return Str :: camel ( substr ( $ caller [ 'function' ] , 3 , - 9 ) ) ; }
|
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 -> normalizeToLocale ( $ language -> code ) ; }
|
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 ( $ exception -> getMessage ( ) ) ; throw $ exception ; } return $ statement ; }
|
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 ( $ this -> getElement ( 'select' , [ 'name' => 'shippingMethodOption' , 'label' => 'order.label.shipping_method' , 'options' => $ provider -> getShippingOptions ( ) , ] ) ) ; } } }
|
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 $ included ; } } return $ this -> getDefaultIncludedResource ( $ id , $ type ) ; }
|
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 = $ moufManager -> getInstance ( $ instanceName ) ; if ( $ path && strpos ( $ path , $ instance -> originalPath ) !== false && $ instance -> createPresetsEnabled === true ) { $ imagePath = substr ( $ path , strlen ( $ instance -> originalPath ) + 1 ) ; $ instance -> image ( $ imagePath ) ; if ( is_callable ( $ callback ) ) { $ finalPath = ROOT_PATH . $ instance -> url . DIRECTORY_SEPARATOR . $ imagePath ; $ callback ( $ finalPath ) ; } } } }
|
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 = $ moufManager -> getInstance ( $ instanceName ) ; if ( $ path && strpos ( $ path , $ instance -> originalPath ) !== false ) { $ imagePath = substr ( $ path , strlen ( $ instance -> originalPath ) + 1 ) ; $ instance -> deletePreset ( $ imagePath ) ; if ( is_callable ( $ callback ) ) { $ finalPath = ROOT_PATH . $ instance -> url . DIRECTORY_SEPARATOR . $ imagePath ; $ callback ( $ finalPath ) ; } } } }
|
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 . ")" ; } else { $ js = "jQuery(\"#{$this->options['id']}\").maxlength(" . $ options . ")" ; } $ view -> registerJs ( $ js ) ; }
|
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 ( ! empty ( $ maxLength ) ) { $ field -> inputOptions [ 'maxlength' ] = $ maxLength ; $ id = Html :: getInputId ( $ field -> model , $ field -> attribute ) ; static :: widget ( [ 'selector' => '#' . $ id , 'clientOptions' => $ clientOptions ] ) ; } if ( $ render ) { echo $ field ; } return $ field ; }
|
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 !== null ? $ maxLength : $ defaultValue ; }
|
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 ( ) -> getApplication ( ) -> getName ( ) ) ) ; return ; } $ result = $ configStorage -> write ( $ message -> getConfig ( ) ) ; if ( $ result !== false ) { $ msg = sprintf ( 'Config file created at "<info>%s</info>".' , $ message -> getConfig ( ) -> getFileName ( ) ) ; } else { $ msg = sprintf ( '<error>Error: Could not create and write file "<info>%s</info>". ' . 'Please check file and directory permissions.</error>' , $ message -> getConfig ( ) -> getFileName ( ) ) ; } $ output -> writeln ( $ msg ) ; }
|
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 ( $ position , [ T_CLASS , T_TRAIT ] ) === TRUE ) { return TRUE ; } return FALSE ; }
|
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.