idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
15,200
protected function processImports ( array $ config , $ importDir ) { if ( isset ( $ config [ "inherit" ] ) ) { $ filePath = $ this -> findImportedConfigFile ( $ config [ "inherit" ] , $ importDir ) ; $ inheritedConfig = $ this -> loadConfig ( $ filePath ) ; $ inheritedConfig = $ this -> processImports ( $ inheritedConf...
Load in any dependent configuration files
15,201
public function widgetsInit ( $ activeWidgets = [ ] ) { if ( ! count ( $ activeWidgets ) ) { return ; } foreach ( $ activeWidgets as $ w ) { add_action ( 'widgets_init' , function ( ) use ( $ w ) { if ( isset ( $ w [ 'id' ] ) ) { $ name = isset ( $ w [ 'name' ] ) ? $ w [ 'name' ] : ucfirst ( str_replace ( '_' , ' ' , $...
Builds the definition for a single sidebar and returns the ID . Call on widgets_init action .
15,202
public function group ( closure $ callback ) { if ( $ this -> can_proceed ( ) ) { if ( $ this -> is_group === false ) { $ this -> is_group = true ; $ callback ( ) ; $ this -> is_group = false ; $ this -> shortcircuit = false ; } else { $ callback ( ) ; $ this -> middleware = \ array_diff ( $ this -> middleware , $ this...
Groups routes with the current middleware stack .
15,203
public function when ( $ result ) { if ( \ is_callable ( $ result ) ) { $ result = $ result ( ) ; } if ( $ this -> can_proceed ( ) && $ result !== true ) { $ this -> shortcircuit = true ; } return $ this ; }
Check if a custom expression returns true .
15,204
public function not ( $ result ) { if ( \ is_callable ( $ result ) ) { $ result = $ result ( ) ; } if ( $ this -> can_proceed ( ) && $ result === true ) { $ this -> shortcircuit = true ; } return $ this ; }
Checks that a custom expression does not return true .
15,205
public function using ( $ middleware = [ ] ) { if ( ! \ is_array ( $ middleware ) ) { $ middleware = [ $ middleware ] ; } foreach ( $ middleware as $ callback ) { $ parts = \ explode ( '|' , $ callback ) ; $ args = [ ] ; if ( \ count ( $ parts ) === 2 ) { $ args = \ explode ( ',' , $ parts [ 1 ] ) ; } $ action = $ this...
Apply optional checks to the current route .
15,206
public function view ( $ slug , $ data = [ ] ) { if ( $ this -> can_proceed ( ) ) { $ this -> apply_middleware ( ) ; if ( $ this -> can_proceed ( ) ) { do_action ( "snap_render_view_{$slug}" , Container :: get ( 'request' ) , $ data ) ; View :: render ( $ slug , $ data ) ; $ this -> has_matched_route = true ; echo \ ob...
Render a view and stop any other routes from processing .
15,207
public function dispatch ( $ controller ) { if ( $ this -> can_proceed ( ) ) { $ this -> apply_middleware ( ) ; if ( $ this -> can_proceed ( ) ) { list ( $ class , $ action ) = \ explode ( '@' , $ controller ) ; if ( $ action === null ) { $ action = 'index' ; } $ fqn = '\\Theme\\Http\\Controllers\\' . $ class ; if ( \ ...
Dispatch a controller action .
15,208
public function reset ( ) { if ( $ this -> has_matched_route === false ) { $ this -> shortcircuit = false ; } if ( $ this -> is_group === false ) { $ this -> middleware = [ ] ; } return $ this ; }
Resets internal pointers .
15,209
private function apply_middleware ( ) { if ( empty ( $ this -> middleware ) ) { return ; } foreach ( $ this -> middleware as $ hook => $ args ) { if ( \ apply_filters ( $ hook , Container :: get ( 'request' ) , ... $ args ) !== true ) { $ this -> shortcircuit = true ; } } }
Apply the current stack of middleware to the current route .
15,210
public function setParent ( $ parent ) { if ( ! is_object ( $ parent ) ) { throw new WrongParent ( 'Parent of a helper must be an object, "' . gettype ( $ parent ) . '" was given' ) ; } $ this -> _parent = $ parent ; return $ this ; }
Set a parent
15,211
public function validateFile ( File $ file ) { if ( ! $ this -> acceptsExtension ( $ file -> getExtension ( ) ) ) { throw new Exception \ InvalidFileException ( sprintf ( "This definition does not accept files with extension %s" , $ file -> getExtension ( ) ) ) ; } if ( ! $ this -> acceptsMime ( $ file -> getMime ( ) )...
Return true if FileHandlerDefinition accepts a given file otherwise throw an exception on failure .
15,212
public function setRequiredType ( $ type ) { if ( ! in_array ( $ type , array ( 'file' , 'directory' ) ) ) { throw new \ InvalidArgumentException ( "Input type must be either 'file' or 'directory'." ) ; } if ( $ type === 'directory' ) { $ this -> setAllowDirectory ( true ) ; } else { $ this -> setAllowDirectory ( false...
Set required file input type must be either file or directory
15,213
public function redirect_to_login ( $ redirect_after = null , $ status = 302 ) { if ( $ redirect_after === null ) { $ redirect_after = Theme_Utils :: get_current_url ( ) ; } $ this -> redirect ( \ wp_login_url ( $ redirect_after ) , $ status ) ; }
Redirects the user to the current login URL .
15,214
public function setPaginator ( PaginatorInterface $ paginator ) { $ this -> _paginator = $ paginator ; $ this -> _pageParam = $ paginator -> getPageParam ( ) ; return $ this ; }
Set the paginator
15,215
public function setUrlParams ( array $ params ) { foreach ( $ params as $ param => $ value ) { $ this -> setUrlParam ( $ param , $ value ) ; } return $ this ; }
Set a common url params
15,216
protected function _renderUrl ( $ control ) { $ params = $ this -> getUrlParams ( ) ; $ params [ $ this -> _pageParam ] = $ control ; if ( $ this -> _urlAssembler === null ) { return $ this -> _baseUrl . '?' . http_build_query ( $ params ) ; } return $ this -> _urlAssembler -> __invoke ( $ params ) ; }
Render the url
15,217
public static function StreamOrDownloadFileFromPath ( string $ filePath , string $ name = null , bool $ deleteOnCompleted = true , bool $ inlineDisposition = true , bool $ knownSize = true ) : BinaryFileResponse { $ name = $ name ? : static :: getFileBaseName ( $ filePath ) ; $ stream = ( $ knownSize === true ? $ fileP...
This will send the file while the browser decides if to open or output for download .
15,218
public function watch ( Url $ attribute ) { $ this -> propertyNames [ $ attribute -> getMetaModel ( ) -> getTableName ( ) ] [ $ attribute -> getColName ( ) ] = $ attribute ; }
Register an attribute
15,219
public function AddParent ( $ parent ) { $ parent = str_replace ( "::" , "\\" , $ parent ) ; $ this -> parents [ $ parent ] = $ parent ; $ this -> has_parent = true ; return $ this ; }
Add a parent class .
15,220
public function AddVariable ( \ Peg \ Lib \ Definitions \ Element \ ClassVariable $ variable ) { $ variable -> parent_class = & $ this ; $ this -> variables [ $ variable -> name ] = $ variable ; return $ this ; }
Adds a variable to the class .
15,221
public function AddEnumeration ( \ Peg \ Lib \ Definitions \ Element \ Enumeration $ enumeration ) { $ enumeration -> parent_class = & $ this ; $ this -> enumerations [ $ enumeration -> name ] = $ enumeration ; return $ this ; }
Adds an enumeration to the class .
15,222
public static function convertToBytes ( string $ value ) : int { $ units = "BKMGT" ; $ unit = preg_replace ( "/[^$units]/i" , "" , $ value ) ; $ value = floatval ( $ value ) ; if ( $ unit ) { $ value *= pow ( 1024 , stripos ( $ units , $ unit [ 0 ] ) ) ; } return ( int ) $ value ; }
Convert a size string into a bytes integer
15,223
public function get ( string $ key ) { if ( ! isset ( $ this -> values [ $ key ] ) ) { $ value = ini_get ( $ key ) ; switch ( self :: CONVERSIONS [ $ key ] ?? 0 ) { case self :: CONVERT_TO_BOOL : $ value = Str :: toBoolean ( $ value ) ; break ; case self :: CONVERT_TO_INT : $ value = ( int ) $ value ; break ; case self...
Retrieve an ini value
15,224
public static function requireModule ( $ module ) { $ file_path = DIR_MODULES . $ module . '/' . 'Module' . Converter :: toCamelCase ( $ module ) . '.php' ; if ( file_exists ( $ file_path ) ) { require_once $ file_path ; if ( MODE == 'cms' ) { $ file_path = DIR_MODULES . $ module . '/' . 'Cms' . ucfirst ( $ module ) . ...
Search for exclusive module CMS pages created in Project folder for this individual site
15,225
public function unserializeData ( $ value ) { if ( \ is_array ( $ value ) ) { return $ value ; } if ( 0 === strpos ( $ value , 'a:' ) ) { return \ unserialize ( $ value , [ 'allowed_classes' => false ] ) ; } return $ value ; }
Unserialize the value from the database if possible return the value as is otherwise .
15,226
public function findOneById ( $ id ) { $ response = $ this -> get ( $ this -> baseUri . 'show.json' , array ( 'id' => $ id ) ) ; return $ this -> mapResponseToObjects ( $ response , Tweet :: class ) ; }
Find one tweet by id
15,227
public static function findAllEntitiesByCriteria ( array $ criteria = [ ] , array $ exclude = [ ] ) : array { $ class = static :: class ; $ obj_collection = new $ class ( ) ; foreach ( $ criteria as $ k => $ v ) { $ obj_collection -> addSimpleWhereField ( $ k , $ v ) ; } foreach ( $ exclude as $ k => $ v ) { $ obj_coll...
Return array of Entity by array of criteria
15,228
public static function findOneEntityByCriteria ( array $ criteria = [ ] , array $ exclude = [ ] ) { $ class = static :: class ; $ obj_collection = new $ class ( ) ; $ obj_collection -> setLimit ( 1 ) ; foreach ( $ criteria as $ k => $ v ) { $ obj_collection -> addSimpleWhereField ( $ k , $ v ) ; } foreach ( $ exclude a...
Return one Entity by array of criteria
15,229
public function getCountOfMaxPossibleFoundObjectsWithoutFilters ( ) : int { $ this -> setGenerateOutputWithIterator ( false ) ; return ( int ) q_value ( $ this -> getSelectSql ( true ) ) ; }
Remove all limits and where fields and get total amount in collection
15,230
public function getByColumn ( string $ column , $ value , $ only_column = null ) { $ result = $ this -> get ( [ 'where' => [ $ column => $ value ] , 'pk' => [ $ column ] , 'single_row' => true , 'skip_acl' => true ] ) ; if ( $ only_column ) { return $ result [ $ only_column ] ?? null ; } else { return $ result ; } }
Get by column
15,231
public static function loadById ( int $ id , string $ column = '' ) { $ class = get_called_class ( ) ; $ model = new $ class ( ) ; $ pk = $ model -> pk ; $ last = array_pop ( $ model -> pk ) ; $ result = $ model -> get ( [ 'where' => [ $ last => $ id ] , 'pk' => [ $ last ] , 'single_row' => true , 'skip_acl' => true ] ...
Load by id
15,232
public function clearAllCaches ( ) { if ( MemcachedCache :: itWorks ( ) ) { $ this -> getMemcachedCacher ( ) -> deleteAll ( ) ; $ clear_file_cache = false ; } if ( MemcacheCache :: itWorks ( ) ) { $ this -> getMemcacheCacher ( ) -> deleteAll ( ) ; $ clear_file_cache = false ; } if ( FileCache :: itWorks ( ) ) { $ this ...
Clears all caches in all available places
15,233
public static function FILTER_SANITIZE_TOKEN ( $ value ) { $ value = preg_replace ( '/[^\w]/' , '' , $ value ) ; $ value = strtoupper ( $ value ) ; return $ value ? : false ; }
not empty token
15,234
public static function FILTER_SANITIZE_TELEPHONE ( $ value ) { $ value = preg_replace ( '/^[^0-9+]+/' , '' , $ value ) ; $ value = preg_replace ( '/^\+39/' , '' , $ value ) ; $ value = preg_replace ( '/^0039/' , '' , $ value ) ; $ value = preg_replace ( '/[\s\(\)]+/' , '' , $ value ) ; if ( preg_match ( '/([0-9]+)(.*)/...
Normalize an italian telephone number empty allowed
15,235
public static function FILTER_SANITIZE_HTTP_URL ( $ value ) { if ( ! preg_match ( '/^http/i' , $ value ) ) { $ value = 'http://' . $ value ; } $ value = filter_var ( $ value , FILTER_VALIDATE_URL ) ; return $ value ? : null ; }
Normalize http url
15,236
public static function FILTER_SANITIZE_ID ( $ value ) { $ value = mb_strtolower ( $ value , 'UTF-8' ) ; $ value = preg_replace ( '/[^\p{L}0-9]+/u' , ' ' , $ value ) ; $ value = preg_replace ( '/\s+/' , '_' , trim ( $ value ) ) ; return $ value ? : false ; }
not null lowercase id
15,237
public static function FILTER_SANITIZE_TURTLE_STRING ( $ value ) { $ value = preg_replace ( '/\\\\/' , '\\\\\\\\' , $ value ) ; $ value = preg_replace ( '/\r?\n|\r/' , '\\n' , $ value ) ; $ value = preg_replace ( '/"/' , '\\"' , $ value ) ; return $ value ? : null ; }
escape double quotes backslash and new line empty allowed
15,238
public static function FIND_MULTIPLIER ( $ value ) { if ( preg_match ( static :: UNITS_REGEXP , $ value , $ matches ) ) { switch ( $ matches [ 1 ] ) { case 'hundred' : $ multiplier = 100 ; break ; case 'thousand' : $ multiplier = 1000 ; break ; case 'million' : $ multiplier = 1000000 ; break ; case 'billion' : $ multip...
parses a string and find inside one of muplier unit
15,239
public static function PARSE_QUANTITATIVE_VALUE ( $ value ) { $ multiplier = static :: FIND_MULTIPLIER ( $ value ) ; $ value = preg_replace ( '/to/' , '..' , $ value ) ; $ value = preg_replace ( '/[^+\.\-<>\d]/' , '' , $ value ) ; if ( preg_match ( '/(-?\d+\.?\d*)(-|\.\.)(-?\d+\.?\d*)/' , $ value , $ matches ) ) { $ mi...
Parse a range string an returns mi and max values if max is not specified max = PHP_INT_MAX if min is not specified min = - PHP_INT_MAX
15,240
public static function FILTER_SANITIZE_GENDER ( $ value ) { if ( preg_match ( '/^\s*m/i' , $ value ) ) { $ value = 'http://schema.org/Male' ; } elseif ( preg_match ( '/^\s*f/i' , $ value ) ) { $ value = 'http://schema.org/Female' ; } else { $ value = null ; } ; return $ value ; }
Only things M or F allowed empty allowed
15,241
public static function FILTER_SANITIZE_PERSON_NAME ( $ value ) { $ value = preg_replace ( '/\s+/' , ' ' , $ value ) ; $ value = mb_strtoupper ( $ value , 'UTF-8' ) ; $ value = trim ( $ value ) ; return $ value ? : null ; }
empty allowed multibyte uppercase
15,242
public static function SANITIZE_STORAGE_CAPACITY ( $ value ) { if ( preg_match ( '/^\s*(\d+\.?\d*)\s*(MB|GB|TB|PB)?\s*$/' , $ value , $ matches ) ) { if ( empty ( $ matches [ 2 ] ) ) { $ matches [ 2 ] = 'TB' ; } ; $ value = $ matches [ 1 ] * static :: FIND_STORAGE_MULTIPLIER ( $ matches [ 2 ] ) ; return "$value..$value...
this function normalize Storage Capacity in TB
15,243
protected function iteratoToArray ( Traversable $ config ) { $ config = iterator_to_array ( $ config ) ; foreach ( $ config as & $ value ) { if ( $ value instanceof Traversable ) { $ value = $ this -> iteratoToArray ( $ value ) ; } } unset ( $ value ) ; return $ config ; }
Recursive iterator to array
15,244
public function accessUrlAccessManagement ( $ slug ) { if ( empty ( $ slug ) || 'wp-login.php' === $ slug ) { return ; } add_filter ( 'login_redirect' , function ( ) use ( $ slug ) { return site_url ( ) . $ slug ; } ) ; add_filter ( 'site_url' , function ( $ url ) use ( $ slug ) { return str_replace ( 'wp-login.php' , ...
Hiding wp - login . php in the login and registration URLs
15,245
public function loginErrorAccessManagement ( $ error ) { $ message = is_bool ( $ error ) && $ error ? Translate :: t ( 'configuration.accessmanagement.login.error' ) : $ error ; add_filter ( 'login_errors' , function ( ) use ( $ message ) { if ( ! empty ( $ message ) ) { return $ message ; } } ) ; }
Redisign wp - login . php page with custom error message .
15,246
public function loginHeaderAccessManagement ( $ args ) { if ( ! $ args ) { return ; } $ configs = array_merge ( [ 'url' => OL_ZEUS_HOME , 'title' => OL_ZEUS_NAME , ] , $ args ) ; add_filter ( 'login_headerurl' , function ( ) use ( $ configs ) { if ( ! empty ( $ configs [ 'url' ] ) ) { return $ configs [ 'url' ] ; } } )...
Redisign wp - login . php page with custom header configurations .
15,247
public function loginStyleAccessManagement ( $ args ) { if ( ! $ args ) { return ; } $ configs = array_merge ( [ 'scripts' => [ ] , 'styles' => [ ] , ] , $ args ) ; add_action ( 'login_enqueue_scripts' , function ( ) use ( $ configs ) { if ( ! empty ( $ configs [ 'scripts' ] ) ) { return ; } foreach ( $ configs [ 'scri...
Redisign wp - login . php page with custom style and scripts .
15,248
public function replaceTags ( $ tag , $ blnCache = true ) { $ parts = explode ( '::' , $ tag ) ; if ( method_exists ( $ this , $ parts [ 0 ] ) ) { $ method = $ parts [ 0 ] ; array_shift ( $ parts ) ; return $ this -> $ method ( $ parts , $ blnCache ) ; } return false ; }
replace tags for the hook delegates to each supported tag
15,249
protected function icon ( $ parts , $ cache ) { return Icons :: generateIcon ( $ parts [ 0 ] , isset ( $ parts [ 1 ] ) ? $ parts [ 1 ] : null ) ; }
generate an icon using insert tag
15,250
public function getResources ( ) { $ data = $ this -> executeJson ( sprintf ( 'project/%s/resources/' , $ this -> ensureParameter ( 'slug' ) ) ) ; $ resources = array ( ) ; foreach ( $ data as $ entry ) { $ resource = new TranslationResource ( $ this -> getTransport ( ) ) ; $ resource -> setProject ( $ this ) ; $ resou...
Retrieve all resources of this project .
15,251
public function getResource ( $ slug ) { $ resource = new TranslationResource ( $ this -> getTransport ( ) ) ; $ resource -> setProject ( $ this -> getSlug ( ) ) ; $ resource -> setSlug ( $ slug ) ; $ resource -> fetchDetails ( ) ; return $ resource ; }
Retrieve a single resource with a given slug .
15,252
public static function create ( $ type , array $ props ) { try { $ component = self :: create_registered_component ( $ type , $ props ) ; } catch ( \ RuntimeException $ ex ) { $ component = self :: create_core_component ( $ type , $ props ) ; } return $ component ; }
Create a UI component instance .
15,253
public static function register ( $ type , $ class_name ) { if ( ! in_array ( $ type , self :: $ registered_components ) ) { self :: $ registered_components [ $ type ] = $ class_name ; } else throw new \ RuntimeException ( "A component of type '$type' has already been registered." ) ; }
Register a custom component class . If the given component name is similar to the name of one of the core components it will override it . If a custom component with a similar name has already been registered an exception will be thrown .
15,254
private function traverse ( array $ registry ) : array { foreach ( $ registry as & $ value ) { switch ( true ) { case is_array ( $ value ) : $ value = $ this -> traverse ( $ value ) ; break ; case is_string ( $ value ) : $ value = $ this -> replace ( $ value ) ; break ; } } return $ registry ; }
Traverse through registry tree
15,255
private function replace ( $ value ) : string { switch ( true ) { case 1 === preg_match ( '/^@env\((.*)\)$/i' , $ value , $ matches ) : $ value = getenv ( $ matches [ 1 ] ) ; break ; } return $ value ; }
Replace special values with actual value
15,256
public function merge ( Model $ object ) { $ mergeData = $ object -> toArray ( ) ; $ this -> _data = $ mergeData + $ this -> _data ; $ this -> _changed += array_fill_keys ( array_keys ( $ mergeData ) , true ) ; return $ this ; }
Merge data of an object into this object
15,257
public function setValues ( array $ values ) { $ this -> _data = $ values + $ this -> _data ; $ this -> _changed += array_fill_keys ( array_keys ( $ values ) , true ) ; return $ this ; }
Set model s values
15,258
public function uninitialize ( ) { if ( empty ( $ this -> _initialized ) ) { return $ this ; } foreach ( array_keys ( $ this -> _initialized ) as $ property ) { unset ( $ this -> _data [ $ property ] ) ; } return $ this ; }
Remove initialized data
15,259
protected function _initialize ( $ property , $ method ) { if ( is_string ( $ method ) ) { $ mode = self :: MODE_JOIN ; $ sourcePrimary = null ; } elseif ( is_array ( $ method ) ) { if ( isset ( $ method [ self :: SOURCE_METHOD ] , $ method [ self :: SOURCE_MODE ] ) ) { $ sourcePrimary = isset ( $ method [ self :: SOUR...
Lazy initialization of data
15,260
private function _initOne ( $ property , $ method , $ mode ) { $ data = $ this -> __call ( $ method ) ; if ( $ data === null ) { return ; } if ( $ data instanceof Collection ) { if ( $ mode !== self :: MODE_CASCADE_MANY ) { throw new Exception ( 'Model hasn\'t a parental collection' ) ; } $ this -> _data [ $ property ]...
Get a data for this model
15,261
private function _initMany ( $ property , $ method , $ mode , $ sourcePrimary ) { $ collection = $ this -> getCollection ( ) ; $ data = $ collection -> __call ( $ method ) ; if ( $ data === null ) return ; if ( $ data instanceof Collection ) { if ( $ data -> hasMetadata ( ) ) { $ meta = $ data -> getMetadata ( ) ; $ on...
Get a data for all models in a collection
15,262
public function isValid ( $ property = null ) { $ validators = $ this -> getValidators ( ) ; if ( $ validators === null ) { return true ; } if ( $ property === null ) { $ data = & $ this -> _data ; } else if ( is_array ( $ property ) ) { $ data = array_intersect_key ( $ this -> _data , array_flip ( $ property ) ) ; if ...
Is data valid
15,263
public function getValidationMessages ( $ property = null ) { if ( $ this -> _validatorsMessages === null ) { return ; } if ( $ property === null ) { return $ this -> _validatorsMessages ; } if ( isset ( $ this -> _validatorsMessages [ $ property ] ) ) { return $ this -> _validatorsMessages [ $ property ] ; } }
Get the validation messages
15,264
public function getValidators ( ) { if ( $ this -> _validators === false ) { return ; } if ( $ this -> _validators === null ) { $ definition = $ this -> getValidationDefinition ( ) ; if ( $ definition === null ) { $ this -> _validators = false ; return ; } $ validators = [ ] ; foreach ( $ definition as $ propName => $ ...
Get the data validators
15,265
public function getValidatorsLocator ( ) { if ( $ this -> _validatorsLocator === null ) { if ( $ this -> hasLocator ( ) ) { $ this -> _validatorsLocator = $ this -> getLocator ( ) -> get ( 'validatorsLocator' ) ; if ( ! $ this -> _validatorsLocator instanceof LocatorByArgumentsInterface ) { throw new Exception ( 'Valid...
Get validators locator
15,266
public function inc ( $ property , $ value = 1 ) { if ( isset ( $ this -> _data [ $ property ] ) ) { $ this -> _data [ $ property ] += $ value ; } else { $ this -> _data [ $ property ] = $ value ; } $ this -> _changed [ $ property ] = true ; return $ this -> _data [ $ property ] ; }
Increase a value of the property Property will be created if not exists
15,267
public function dec ( $ property , $ value = 1 ) { if ( isset ( $ this -> _data [ $ property ] ) ) { $ this -> _data [ $ property ] -= $ value ; } else { $ this -> _data [ $ property ] = - $ value ; } $ this -> _changed [ $ property ] = true ; return $ this -> _data [ $ property ] ; }
Decrease a value of the property Property will be created if not exists
15,268
public function __isset ( $ name ) { if ( isset ( $ this -> _data [ $ name ] ) ) { return true ; } if ( method_exists ( $ this , lcfirst ( $ name ) . self :: INIT_POSTFIX ) ) { return true ; } if ( ! empty ( $ this -> _sources [ $ name ] ) ) { return true ; } return false ; }
Is the property exists
15,269
public function putContents ( $ data = null , $ flag = null , $ context = null ) { file_put_contents ( $ this -> filename , $ data , $ flag , $ context ) ; }
Put contents to the given path if it s file
15,270
public function addDashboardMenuItem ( MenuCollectionEvent $ event ) : void { $ menu = $ event -> getMenu ( ) ; $ dashboard = $ this -> factory -> createItem ( 'menu_item.dashboard' , [ 'route' => 'bkstg_admin_dashboard' , 'extras' => [ 'icon' => 'tachometer-alt' , 'translation_domain' => BkstgCoreBundle :: TRANSLATION...
Add the dashboard menu item .
15,271
public function setStdin ( string $ str ) : Process { $ this -> spec [ self :: STDIN ] = [ "pipe" , "r" ] ; $ this -> stdin = $ str ; return $ this ; }
Set the stdin contents
15,272
public function setStdinFile ( string $ path ) : Process { if ( ! is_readable ( $ path ) ) { throw new \ InvalidArgumentException ( "invalid value provided for 'path'; " . "'$path' is not a readable file" ) ; } $ this -> spec [ self :: STDIN ] = [ "file" , $ path , "r" ] ; $ this -> stdin = "" ; return $ this ; }
Set the path to a file to read into stdin
15,273
private function setOutputFile ( int $ stream , string $ path , bool $ append ) { if ( ! is_writable ( $ path ) ) { throw new \ InvalidArgumentException ( "invalid value provided for 'path'; " . "'$path' is not a writable file" ) ; } $ this -> spec [ $ stream ] = [ "file" , $ path , $ append === true ? "a" : "w" ] ; }
Set an output file for either stdout or stderr
15,274
public function setStdoutFile ( string $ path , bool $ append = false ) : Process { $ this -> setOutputFile ( self :: STDOUT , $ path , $ append ) ; return $ this ; }
Set the path to a file to write stdout to
15,275
public function setStderrFile ( string $ path , bool $ append = false ) : Process { $ this -> setOutputFile ( self :: STDERR , $ path , $ append ) ; return $ this ; }
Set the path to a file to write stderr to
15,276
public static function getComponentByPageId ( $ component , $ page_id ) { $ page_id = ( int ) $ page_id ; $ component = sql_prepare ( $ component ) ; $ cache_key = 'components_' . $ page_id . '_c_' . $ component ; $ res = NULL ; if ( Settings :: isCacheEnabled ( ) ) { $ res = Cacher :: getInstance ( ) -> getDefaultCach...
Get one component data by page id and name
15,277
private function findAliasedValue ( string $ column , $ value ) { $ alias = null ; foreach ( $ this -> alias_data as $ k => $ v ) { if ( strpos ( $ column , $ k ) !== false ) { $ alias = $ k ; break ; } } if ( ! empty ( $ alias ) ) { return $ this -> alias_object -> getIdByCode ( $ alias , str_replace ( '::id::' , '' ,...
Find aliased value
15,278
public function initialize ( ) { if ( $ this -> initialized ) return ; $ this -> data = $ this -> session -> get ( self :: BASE_KEY , array ( ) ) ; $ this -> clear ( ) ; $ this -> initialized = true ; }
Initialize data by call Although instantiating this instance will basically initialize the data .
15,279
public function set ( $ key , $ value ) { $ this -> session -> set ( self :: BASE_KEY . '.' . $ key , $ value ) ; return $ this ; }
Flash the value on the given key .
15,280
public function setResponse ( iterable $ response ) : ResponseSelector { if ( ! $ response instanceof Collection ) { $ response = new Collection ( $ response ) ; } $ this -> response = $ response ; return $ this ; }
Sets the current response array
15,281
public function entityByResult ( string $ entity ) : array { $ result = array_get ( $ this -> response , "data.result" , '' ) ; return array_get ( $ this -> response , "data.entities.$entity.$result" , [ ] ) ; }
Returns an entity by current response result
15,282
public function actionIndex ( ) { $ searchModel = new SearchProduct ( ) ; $ dataProvider = $ searchModel -> search ( Yii :: $ app -> request -> queryParams ) ; $ notModeratedProductsCount = Product :: find ( ) -> where ( [ 'status' => Product :: STATUS_ON_MODERATION ] ) -> count ( ) ; return $ this -> render ( 'index' ...
Displays products list .
15,283
public function actionDeleteImage ( $ id , $ languageId ) { if ( ! empty ( $ id ) ) { $ image = ProductImage :: find ( ) -> where ( [ 'id' => $ id ] ) -> one ( ) ; if ( ! empty ( $ image ) ) { $ product = Product :: findOne ( $ image -> product_id ) ; if ( \ Yii :: $ app -> user -> can ( 'updateProduct' , [ 'productOwn...
Users which have updateOwnProduct permission can delete image only from Product models that have been created by their . Users which have updateProduct permission can delete image from all Product models .
15,284
public function actionImageDown ( $ id , $ languageId ) { $ productImage = ProductImage :: findOne ( $ id ) ; if ( \ Yii :: $ app -> user -> can ( 'updateProduct' , [ 'productOwner' => Product :: findOne ( $ productImage -> product_id ) -> owner ] ) ) { if ( $ productImage ) { $ productImage -> moveNext ( ) ; $ this ->...
Changes ProductImage position to down
15,285
public function actionDeleteVideo ( $ id , $ languageId ) { if ( ! empty ( $ id ) ) { $ video = ProductVideo :: findOne ( $ id ) ; $ product = Product :: findOne ( $ video -> product_id ) ; if ( \ Yii :: $ app -> user -> can ( 'updateProduct' , [ 'productOwner' => $ product -> owner ] ) ) { if ( $ video -> resource == ...
Users which have updateOwnProduct permission can delete video only from Product models that have been created by their . Users which have updateProduct permission can delete video from all Product models .
15,286
public function actionChangeProductStatus ( $ id , $ status ) { if ( ! empty ( $ id ) && ! empty ( $ status ) ) { $ product = Product :: findOne ( $ id ) ; if ( $ product -> status == Product :: STATUS_ON_MODERATION ) { switch ( $ status ) { case Product :: STATUS_SUCCESS : $ product -> status = Product :: STATUS_SUCCE...
Changes product status property by ModerationManager
15,287
public function actionUp ( $ id ) { $ product = Product :: findOne ( $ id ) ; if ( \ Yii :: $ app -> user -> can ( 'updateProduct' , [ 'productOwner' => $ product -> owner ] ) ) { if ( ! empty ( $ product ) ) { $ product -> movePrev ( ) ; $ this -> trigger ( self :: EVENT_AFTER_EDIT_PRODUCT , new ProductEvent ( [ 'id' ...
Changes product position to up
15,288
public function actionDelete ( $ id ) { $ product = Product :: findOne ( $ id ) ; if ( empty ( $ product ) ) throw new NotFoundHttpException ( ) ; if ( \ Yii :: $ app -> user -> can ( 'deleteProduct' , [ 'productOwner' => $ product -> owner ] ) ) { $ this -> trigger ( self :: EVENT_BEFORE_DELETE_PRODUCT ) ; SeoData :: ...
Deletes product .
15,289
public function actionGenerateSeoUrl ( $ title ) { $ newSeoUrl = Inflector :: slug ( $ title ) ; $ seoUrl = SeoData :: find ( ) -> where ( [ 'entity_name' => ProductTranslation :: className ( ) , 'seo_url' => $ newSeoUrl ] ) -> one ( ) ; if ( ! empty ( $ seoUrl ) ) $ newSeoUrl = $ newSeoUrl . '-' . date ( "d-m-y-H-i-s"...
Generates seo Url from title on add - basic page
15,290
public static function makeResourceRepository ( string $ repository ) : Repository { $ api = App :: make ( ApiClient :: class ) ; return new $ repository ( $ api ) ; }
Make a resource repository instance
15,291
private function updateRepr ( ) { $ this -> message = $ this -> rawMessage ; $ items = "'" . implode ( "', '" , $ this -> items ) . "'" ; $ this -> message = strtr ( $ this -> message , [ '%name%' => $ this -> itemName , '%items%' => $ items ] ) ; }
Updates the message representation with the item name and items .
15,292
public static function feed ( $ user , $ take = 50 ) { return static :: where ( 'user_id' , $ user -> id ) -> latest ( ) -> with ( 'subject' ) -> take ( $ take ) -> get ( ) -> groupBy ( function ( $ activity ) { return $ activity -> created_at -> format ( 'Y-m-d' ) ; } ) ; }
Fetch an activity feed for the given user .
15,293
public static function Sort ( $ data_array , $ field_name , $ sort_method = SORT_ASC ) { $ sorted_array = array ( ) ; if ( is_array ( $ data_array ) ) { $ field_to_sort_by = array ( ) ; $ new_id_position = array ( ) ; foreach ( $ data_array as $ key => $ fields ) { $ field_to_sort_by [ $ key ] = $ fields [ $ field_name...
Sorts an array of listener function using bubble sort .
15,294
public function setupMail ( ) { if ( $ this -> options === null ) { throw new NullValueException ( 'Mail options not set on ' . get_class ( $ this ) ) ; } $ params = [ 'to' , 'from' , 'cc' , 'bcc' , 'replyTo' , 'subject' ] ; foreach ( $ params as $ param ) { if ( isset ( $ this -> options -> $ param ) ) { $ this -> $ p...
Setup mail values
15,295
public static function getTermIdbyName ( $ name , $ type = self :: TYPE_TAG ) { $ tag = get_term_by ( 'name' , $ name , $ type ) ; return ( $ tag ) ? $ tag -> term_id : 0 ; }
Return the ID from the tag name
15,296
public static function getAll ( ) { global $ wpdb ; if ( false === ( $ results = get_transient ( self :: TRANSIENT_ALL_TAGS ) ) ) { $ results = $ wpdb -> get_results ( ' SELECT ta.term_taxonomy_id as taxonomy_id, name, slug, count(*) total FROM ' . $ wpdb -> prefix . 'term_taxonomy ta JOIN ' . $ wpdb -> prefix...
Get all tags
15,297
public function map_comments_template_to_partials ( $ path ) { $ tpl = \ str_replace ( [ STYLESHEETPATH , TEMPLATEPATH , '.' ] , [ '' , '' , '/' ] , $ path ) ; $ locate = \ locate_template ( Theme_Utils :: get_path_to_partial ( $ tpl ) , false ) ; if ( $ locate !== '' ) { return $ locate ; } $ locate = \ locate_templat...
Attempt to map the file passes into comments_template to a partial .
15,298
public function getType ( ) { $ userType = get_user_meta ( $ this -> ID , self :: KEY_TYPE , true ) ; return ( $ userType ) ? $ userType : self :: TYPE_DEFAULT ; }
Return the user type
15,299
public function getAvatar ( $ size = self :: AVATAR_SIZE_DEFAULT ) { $ avatar = $ this -> getImage ( self :: KEY_AVATAR , $ size , $ size ) ; if ( empty ( $ avatar ) ) { return static :: getUrlAvatar ( $ size ) ; } return $ avatar ; }
Return the URL with the avatar from the User