idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
12,700
public function url ( $ image , ? string $ alt = null , array $ extra = [ ] , bool $ default = false ) : ? string { return $ this -> generateImagePayload ( $ image , $ alt , $ extra , $ default ) -> url ?? null ; }
Get url for image
12,701
public function storageUrl ( $ image , ? string $ alt = null , array $ extra = [ ] ) : ? string { return $ this -> generateImagePayload ( $ image , $ alt , $ extra , true , true ) -> url ?? null ; }
Get url for local storage image
12,702
protected function generateImagePayload ( $ image , ? string $ alt , array $ extra , bool $ default , bool $ storage = false ) : ? ResourceSettings { $ image = $ this -> createImageSettings ( $ image , $ alt , $ extra , $ default , $ storage ) ; if ( $ this -> hasCachedImage ( $ image ) ) { return $ this -> getCachedIm...
Create the image payload
12,703
protected function cacheImage ( ResourceSettings $ image ) : ResourceSettings { $ this -> resources -> add ( $ image -> key , $ image ) ; return $ image ; }
Store image in the cache
12,704
protected function generateHtmlOutput ( ResourceSettings $ image ) : string { $ str = <<<'IMAGESTR'<img src="{{url}}" alt="{{alt}}" {{title}} {{width}} {{height}} {{class}} {{id}} {{cors}} {{extra}} />IMAGESTR ; return Str :: format ( $ str , [ 'url' => $ image -> url , 'alt' => e ( $ image -> alt ) , 'title' => $ ima...
Images output string
12,705
protected function getLocalImageSettings ( $ image , ? string $ alt , array $ extra , bool $ default , bool $ storage = false ) : ResourceSettings { if ( $ image instanceof LocalSettings ) { $ settings = $ image ; } elseif ( is_array ( $ image ) ) { if ( ! empty ( $ extra ) ) { $ image [ 'extra' ] = array_merge ( $ ima...
Create settings for local image
12,706
protected function getStorageUrl ( $ image ) : string { if ( is_array ( $ image ) ) { array_unshift ( $ image , 'storage' ) ; } else { $ image = 'storage/' . ltrim ( $ image ) ; } return $ this -> url -> to ( $ image ) ; }
Get storage url
12,707
protected function parse ( array $ definitions ) { foreach ( $ this -> rawParams as $ rKey => $ rVal ) { if ( array_key_exists ( $ rKey , $ definitions ) ) { if ( is_array ( $ rVal ) ) { $ value = array ( ) ; foreach ( $ rVal as $ key => $ val ) { $ value [ $ key ] = $ this -> validateValue ( $ val , $ definitions [ $ ...
Parse the passed in parameters and ensure that they conform to the definition
12,708
private function handleUndefinedParameters ( ) { $ leftover = count ( $ this -> rawParams ) ; if ( 0 < $ leftover ) { if ( 1 == $ leftover ) { $ msg = 'The parameter \'%s\' is not valid' ; } else { $ msg = 'The parameters \'%s\' are not valid' ; } throw new \ Exception ( sprintf ( $ msg , implode ( '\', \'' , array_key...
Throw an exception if a parameter that is not in the definition was passed in the parameter array
12,709
private function handleMissingRequiredParameters ( ) { $ leftover = count ( $ this -> requiredParams ) ; if ( 0 < $ leftover ) { if ( 1 == $ leftover ) { $ msg = 'The required parameter \'%s\' is missing' ; } else { $ msg = 'The required parameters \'%s\' are missing' ; } throw new \ Exception ( sprintf ( $ msg , implo...
Throw an exception if a required parameter is missing
12,710
protected function validateValue ( $ value , $ definition ) { try { return $ definition -> getValidator ( ) -> validate ( $ value ) ; } catch ( \ Exception $ e ) { throw new \ Exception ( sprintf ( '[%s] %s' , $ definition -> getName ( ) , $ e -> getMessage ( ) ) ) ; } }
Run the value through the configured validator
12,711
public static function buildLogger ( ContainerInterface $ container ) { $ factory = new MonologFactory ( $ container -> getParameter ( 'kernel.log_dir' ) , $ container -> getParameter ( 'kernel.env' ) ) ; return ( $ factory -> getServiceClass ( ) ) ; }
buildLogger Build the logger service
12,712
public static function buildTemplating ( ContainerInterface $ container ) { $ factory = new TwigFactory ( $ container -> getParameter ( 'kernel.template_dir' ) , $ container -> getParameter ( 'kernel.cache_dir' ) , $ container -> getParameter ( 'kernel.env' ) ) ; return ( $ factory -> getServiceClass ( ) ) ; }
buildTemplating Build the twig templating service
12,713
private function init ( InputInterface $ input , OutputInterface $ output ) { $ this -> helper = $ this -> getHelper ( 'question' ) ; $ this -> input = $ input ; $ this -> output = $ output ; $ this -> force = $ input -> getOption ( 'force' ) ; $ this -> root = $ input -> getOption ( 'root' ) ; $ this -> init_wordpress...
Set up class properties and initialise Snap .
12,714
private function get_packages ( ) { if ( $ this -> input -> getOption ( 'all' ) === true ) { $ packages = [ ] ; foreach ( Config :: get ( 'services.providers' ) as $ package ) { $ packages [ $ package ] = $ package :: get_files_to_publish ( ) ; } return $ packages ; } $ package = $ this -> input -> getOption ( 'package...
Gets a list of packages and their files to publish .
12,715
private function publish_packages ( $ packages ) { if ( empty ( $ packages ) ) { return ; } foreach ( $ packages as $ package => $ directories_to_publish ) { if ( empty ( $ directories_to_publish ) ) { $ this -> output -> writeln ( "<comment>$package has no files to publish!</comment>" ) ; continue ; } $ this -> publis...
Loop through all user selected packages and publish the package files .
12,716
private function publish_directories ( $ directories ) { $ root = \ get_template_directory ( ) ; if ( \ is_child_theme ( ) ) { $ root = \ get_stylesheet_directory ( ) ; } if ( isset ( $ this -> root ) ) { $ root = $ this -> root ; } foreach ( $ directories as $ source => $ target ) { $ target_path = \ trailingslashit (...
Loop through all directories to be published by the selected package and attempt to create them .
12,717
private function mkdir ( $ target ) { if ( \ is_dir ( $ target ) ) { return ; } if ( ! $ this -> file -> mkdir ( $ target ) ) { $ this -> output -> writeln ( "<error>[$target] could not be created. Please check directory permissions.</error>" ) ; } }
Attempt to create the target directory .
12,718
private function force_prompt ( ) { if ( $ this -> force === false ) { return ; } $ question = new ConfirmationQuestion ( "\n<error>Force flag enabled. Any published files will overwrite target files if they exist.</error> \n\nContinue? " , false ) ; if ( ! $ this -> helper -> ask ( $ this -> input , $ this -> output ,...
Ask if the user wishes to continue with the force flag enabled .
12,719
private function package_prompt ( ) { $ question = new ChoiceQuestion ( "\nPlease choose a package to publish:" , Config :: get ( 'services.providers' ) ) ; $ question -> setErrorMessage ( '[%s] is invalid.' ) ; return $ this -> helper -> ask ( $ this -> input , $ this -> output , $ question ) ; }
Prompts the user to pick a package from the list .
12,720
protected function getConfiguration ( InputInterface $ input ) { $ configuration = new Configuration ( ) ; $ configuration -> setImagine ( $ this -> getImagine ( $ input -> getOption ( 'driver' ) ) ) ; $ configuration -> setOptions ( $ input -> getOption ( 'options' ) ) ; $ configuration -> getFinder ( ) -> name ( $ in...
Returns a Configuration instance .
12,721
protected function getImagine ( $ driver = null ) { if ( null === $ driver ) { switch ( true ) { case function_exists ( 'gd_info' ) : $ driver = 'gd' ; break ; case class_exists ( 'Gmagick' ) : $ driver = 'gmagick' ; break ; case class_exists ( 'Imagick' ) : $ driver = 'imagick' ; break ; } } if ( ! in_array ( $ driver...
Returns an ImagineInterface instance .
12,722
public function get ( $ name , array $ parameters = [ ] , $ flag = false ) { return $ flag ? $ this -> getContainer ( ) -> instance ( $ name , $ parameters ) : $ this -> getContainer ( ) -> singleton ( $ name , $ parameters ) ; }
Get custom defined helper obj .
12,723
public function get_placeholder_image ( $ post_id , $ post_thumbnail_id , $ size , $ attr = [ ] ) { $ original_size = $ size ; $ post_id = $ post_id ?? \ get_the_id ( ) ; if ( Image_Utils :: get_image_size ( $ size ) === false ) { $ size = 'full' ; } $ placeholder_url = $ this -> search_for_placeholder ( 'placeholder-'...
Searches for a suitable placeholder fallback image .
12,724
public function listing ( $ currency , array $ types = [ ] ) { $ types = implode ( ',' , $ types ) ; return $ this -> merchantApi -> call ( 'get' , sprintf ( 'channels?currency=%s&type=%s' , strtoupper ( $ currency ) , $ types ) ) -> toArray ( ) ; }
Lists currently available payment channels for a given currency You can optionally filter channels by providing types of the channels as an array . See constants declared above .
12,725
public static function makeUrl ( array $ params ) : string { $ href = [ ] ; foreach ( $ params as $ key => $ value ) { $ href [ ] = static :: makeParam ( $ key , ( string ) $ value ) ; } return '?' . implode ( '&' , $ href ) ; }
Return url if key from parameter exists - add parameter value to url
12,726
public function getHelpfulness ( ) { if ( $ this -> hits + $ this -> misses === 0 ) { return 0.00 ; } return number_format ( ( $ this -> hits / ( $ this -> hits + $ this -> misses ) ) * 100 , 2 ) ; }
Get helpfulness percentage
12,727
private function generateSourceSeo ( $ key ) { if ( isset ( $ this -> { $ key } ) ) { return $ this -> { $ key } ; } $ object = $ this ; foreach ( explode ( '.' , $ key ) as $ segment ) { if ( ! is_object ( $ object ) || ! $ tmp = $ object -> { $ segment } ) { return null ; } $ object = $ object -> { $ segment } ; } re...
Get value for seo .
12,728
public static function createFromGlobals ( ) { $ server = $ _SERVER ; $ uriParts = parse_url ( $ server [ 'REQUEST_URI' ] ) ; if ( isset ( $ server [ 'HTTP_HOST' ] ) ) { list ( $ host , $ port ) = explode ( ':' , $ server [ 'HTTP_HOST' ] ) ; $ uriParts [ 'host' ] = $ host ; $ uriParts [ 'port' ] = $ port ; } else { $ u...
Instantiate request from php _SERVER variable
12,729
public static function createFromArray ( array $ params ) { return new static ( isset ( $ params [ 'method' ] ) ? $ params [ 'method' ] : 'GET' , new Uri ( isset ( $ params [ 'uri' ] ) ? $ params [ 'uri' ] : '' ) , isset ( $ params [ 'headers' ] ) ? $ params [ 'headers' ] : array ( ) , isset ( $ params [ 'body' ] ) ? (...
Create request from given array
12,730
public function server ( $ name , $ default = null ) { return array_key_exists ( $ name , $ this -> server ) ? $ this -> server [ $ name ] : $ default ; }
Get server value
12,731
public function getUploadedFile ( $ key ) { if ( isset ( $ this -> uploadedFiles [ $ key ] ) ) return $ this -> uploadedFiles [ $ key ] ; return null ; }
Get UploadedFile from given key
12,732
public function param ( $ name , $ default = null ) { if ( ! $ this -> params ) $ this -> params = $ this -> getMethod ( ) == 'GET' ? $ this -> getQueryParams ( ) : array_merge ( $ this -> getQueryParams ( ) , $ this -> getParsedBody ( ) ) ; return array_key_exists ( $ name , $ this -> params ) ? $ this -> params [ $ n...
Get a merged query params and parsed body
12,733
public function getParams ( ) { if ( ! $ this -> params ) $ this -> params = $ this -> getMethod ( ) == 'GET' ? $ this -> getQueryParams ( ) : array_merge ( $ this -> getQueryParams ( ) , $ this -> getParsedBody ( ) ) ; return $ this -> params ; }
Get merged query params and parsed body
12,734
public function resolveUriPath ( ) { if ( ! $ this -> server ) return ; list ( $ requestUri ) = explode ( '?' , $ this -> server [ 'REQUEST_URI' ] ) ; if ( strpos ( $ requestUri , $ this -> server [ 'SCRIPT_NAME' ] ) === 0 ) { $ basePath = $ this -> server [ 'SCRIPT_NAME' ] ; } else { $ basePath = explode ( '/' , $ thi...
Apache only functionality to resolve uri to current folder the apps is located
12,735
public function getHelpersBroker ( ) { if ( $ this -> _helperBroker === null ) { if ( $ this instanceof LocatorAwareInterface && $ this -> hasLocator ( ) ) { $ this -> _helperBroker = $ this -> getLocator ( ) -> get ( $ this -> getHelpersBrokerServiceId ( ) ) ; if ( ! $ this -> _helperBroker instanceof HelpersLocatorIn...
Get a helper s broker
12,736
public function hasHelpersBroker ( ) { if ( $ this -> _helperBroker !== null ) { return true ; } if ( $ this instanceof LocatorAwareInterface && $ this -> hasLocator ( ) && $ this -> getLocator ( ) -> has ( $ this -> getHelpersBrokerServiceId ( ) ) ) { return true ; } return false ; }
Has a helper broker
12,737
public static function add_resize_configuration ( $ name , $ width , $ height , $ mode = 'auto' ) { $ configuration = [ 'width' => $ width , 'height' => $ height , 'mode' => $ mode ] ; self :: $ resize_configurations [ $ name ] = $ configuration ; }
Add Resize Configuration
12,738
public static function get_resize_configuration ( $ name ) { if ( ! isset ( self :: $ resize_configurations [ $ name ] ) ) { throw new \ Exception ( 'Resize configuration ' . $ name . ' not found' ) ; } return self :: $ resize_configurations [ $ name ] ; }
Get resize configuration
12,739
public function pluck ( $ field , $ index_key = null ) { $ list = new WP_List_Util ( $ this -> all ( ) ) ; return new static ( $ list -> pluck ( $ field , $ index_key ) ) ; }
Creates a new collection with specific values from the current collection items .
12,740
protected function getItems ( $ items ) { if ( \ is_array ( $ items ) ) { return $ items ; } elseif ( $ items instanceof self ) { return $ items -> all ( ) ; } elseif ( $ items instanceof Traversable ) { return \ iterator_to_array ( $ items ) ; } return ( array ) $ items ; }
Sanity check items being passed into constructor .
12,741
public function getStack ( $ imploded = true ) { return ( bool ) $ imploded ? implode ( '.' , $ this -> keystack ) : $ this -> keystack ; }
Fetch the stack either as array or as dot separated string .
12,742
private function readLangString ( ) { while ( ! $ this -> tokenIs ( ';' ) ) { $ this -> getNextToken ( ) ; if ( $ this -> tokenIs ( '[' ) ) { $ this -> subParserSquareBracket ( ) ; continue ; } if ( $ this -> tokenIs ( '=' ) ) { $ this -> getNextToken ( ) ; if ( $ this -> tokenIs ( T_ARRAY ) || $ this -> tokenIs ( '[' ...
Read a language string from the file .
12,743
public function checkIsString ( $ value = false , $ expected = false ) { if ( ! is_string ( $ this -> token ) || ( $ value && ( $ this -> token != $ value ) ) ) { $ this -> bailUnexpectedToken ( $ expected ) ; } }
Ensure that the current token is a string .
12,744
public function checkIsNotString ( $ value = false , $ expected = false ) { if ( is_string ( $ this -> token ) || ( $ value && ( $ this -> token [ 0 ] != $ value ) ) ) { $ this -> bailUnexpectedToken ( $ expected ) ; } }
Ensure the current token is not a string and optionally is of the given value .
12,745
public function tokenIs ( $ type ) { if ( is_string ( $ this -> token ) ) { return ( $ this -> token == $ type ) ; } return ( $ this -> token [ 0 ] == $ type ) ; }
Check whether the current token matches the given value .
12,746
private function advanceToken ( ) { if ( ! ( $ this -> tokenIs ( T_WHITESPACE ) || $ this -> tokenIs ( T_DOC_COMMENT ) ) ) { $ this -> prevToken = $ this -> token ; } $ this -> token = next ( $ this -> tokens ) ; }
Move one token ahead .
12,747
private function skipUntilSearchedToken ( $ searchFor ) { while ( $ this -> token ) { if ( ( is_string ( $ searchFor ) && ( $ searchFor == $ this -> token ) ) || ( is_int ( $ searchFor ) && is_array ( $ this -> token ) && ( $ searchFor == $ this -> token [ 0 ] ) ) ) { break ; } $ this -> advanceToken ( ) ; } }
Skip all tokens until the matched token has been encountered or no more tokens are available .
12,748
private function resolvePaymentsState ( OrderInterface $ order ) { $ capturedTotal = $ authorizedTotal = $ refundTotal = $ failedTotal = 0 ; $ payments = $ order -> getPayments ( ) ; if ( 0 < $ payments -> count ( ) ) { foreach ( $ payments as $ payment ) { if ( $ payment -> getState ( ) == PaymentStates :: STATE_CAPTU...
Resolves the global payment state .
12,749
private function resolveShipmentsState ( OrderInterface $ order ) { if ( ! $ order -> isEmpty ( ) ) { if ( ! $ order -> requiresShipment ( ) ) { return ShipmentStates :: STATE_SHIPPED ; } } return ShipmentStates :: STATE_PENDING ; }
Resolves the global shipment state .
12,750
public function register ( $ settings ) { if ( ! $ this -> enabled ) { return ; } if ( $ this -> buffersize === 0 || $ this -> buffersize === 1 ) { $ this -> write ( $ settings ) ; return ; } $ settings = $ this -> parseSettings ( $ settings ) ; $ payload = $ this -> getPayload ( $ settings ) ; $ this -> buffer [ ] = $...
Registers a new track
12,751
public function write ( $ settings ) : ? Model { if ( ! $ this -> enabled ) { return null ; } $ settings = $ this -> parseSettings ( $ settings ) ; return Tracker :: createNew ( $ this -> getPayload ( $ settings ) ) ; }
Writes registered tracks
12,752
protected function getPayload ( Settings $ settings ) : array { $ settings -> hasRequiredSettings ( ) ; $ now = Carbon :: now ( ) -> toDateTimeString ( ) ; if ( $ this -> config -> get ( 'tracker.save_rendered' , true ) && $ settings -> data !== null ) { $ rendered = markdown ( $ settings -> data ) ; } return [ 'user_i...
Parse settings to array
12,753
private function prepareComponentList ( array $ types ) { $ this -> types = [ ] ; foreach ( $ types as $ type ) { $ this -> types [ $ type -> getKey ( ) ] = $ type ; } }
Prepares the internal data structure
12,754
public function getType ( string $ key ) : ComponentType { if ( ! array_key_exists ( $ key , $ this -> types ) ) { throw new UnknownComponentTypeException ( $ key , array_keys ( $ this -> types ) ) ; } $ type = $ this -> types [ $ key ] ; return $ type ; }
Returns the type by key
12,755
public function getAll ( ) : array { return array_map ( function ( string $ key ) { return $ this -> getType ( $ key ) ; } , array_keys ( $ this -> types ) ) ; }
Returns all component types
12,756
public function getByStockItemId ( $ stockItemId ) { $ where = Entity :: A_STOCK_ITEM_REF . '=' . ( int ) $ stockItemId ; $ result = $ this -> get ( $ where ) ; return $ result ; }
Get all lots quantities for Magento stock item .
12,757
final public function actionslistAction ( ) { $ reflection = new ReflectionObject ( $ this ) ; echo "Available actions:\033[1;32m" ; foreach ( $ reflection -> getMethods ( ReflectionMethod :: IS_PUBLIC ) as $ method ) { $ length = strlen ( $ method -> name ) - 6 ; if ( strpos ( $ method -> name , 'Action' ) === $ lengt...
Show the list of a task s actions
12,758
public function getLocator ( ) { if ( $ this -> _locator === null ) { $ di = $ this -> getDi ( ) ; if ( ! $ di instanceof LocatorInterface ) { throw new NoLocator ( 'Hasn\'t been locator provided' ) ; } $ this -> _locator = $ di ; } return $ this -> _locator ; }
Get a services locator
12,759
protected function getParam ( $ name , $ default = null , $ filters = null ) { return $ this -> getDi ( ) -> get ( 'dispatcher' ) -> getParam ( $ name , $ filters , $ default ) ; }
Get the parameter from the request
12,760
protected function hasParam ( $ name ) { if ( $ this -> getDi ( ) -> get ( 'dispatcher' ) -> getParam ( $ name , null , false ) ) { return true ; } return false ; }
Has the parameter from the request
12,761
protected function scaffold ( $ scaffold , $ args = [ ] , $ options = [ ] ) { $ this -> init_wordpress ( ) ; Snap :: create_container ( ) ; Snap :: init_config ( ) ; $ original = $ this -> scaffolding_dir . "{$scaffold}.txt" ; if ( \ file_exists ( $ original ) ) { $ content = \ file_get_contents ( $ original ) ; if ( !...
Update a scaffold file and put into the active theme .
12,762
protected function get_destination ( $ scaffold , $ args ) { $ sub_dir = '/theme/' ; switch ( $ scaffold ) { case 'shortcode' : $ dir = 'Shortcodes' ; $ sub_dir .= 'Content/' ; break ; case 'ajax' : $ dir = 'Ajax' ; $ sub_dir .= 'Http/' ; break ; case 'hookable' : $ dir = \ trim ( Config :: get ( 'theme.hookables_direc...
Returns the full path of the new file to be created .
12,763
private function parse_args ( $ args = [ ] ) { $ args [ 'NAMESPACE' ] = '' ; $ class_name = $ this -> sanitise_filename ( $ args [ 'CLASSNAME' ] ) ; if ( $ this -> is_nested_directory ( $ class_name ) ) { $ parts = \ explode ( '\\' , $ class_name ) ; $ class = \ array_pop ( $ parts ) ; $ args [ 'NAMESPACE' ] = '\\' . \...
Populates the NAMESPACE argument based off the passed CLASSNAME .
12,764
public function format ( $ value , $ params = null , $ locale = null ) { if ( $ locale === null ) { $ locale = 'en' ; } return $ this -> getFormatter ( $ locale ) -> format ( $ value ) ; }
Format the number
12,765
public function save ( ) { global $ wpdb ; $ isExists = $ wpdb -> get_var ( $ wpdb -> prepare ( 'SELECT COUNT(*) FROM ' . $ wpdb -> prefix . 'comments WHERE comment_ID = %d' , $ this -> comment_ID ) ) ; $ c = 'comment_' ; if ( $ isExists ) { return $ wpdb -> query ( $ wpdb -> prepare ( "UPDATE ' . $wpdb->prefix ....
Save or Update the comment
12,766
public function onRequest ( Application $ application , Request $ request ) { $ params = $ request -> getParameters ( ) ; $ this -> setCode ( $ params [ 'locale' ] ?? $ this -> defaultLocale ) ; }
On request .
12,767
private function checkLocale ( ) { if ( ! isset ( $ this -> locales [ $ this -> selectLocale ] ) ) { if ( isset ( $ this -> aliasLocale [ $ this -> selectLocale ] ) ) { $ this -> selectLocale = $ this -> aliasLocale [ $ this -> selectLocale ] ; } else { $ this -> selectLocale = $ this -> defaultLocale ; } } }
Internal check current locale with apply alias .
12,768
public function getCode ( bool $ upper = false ) : string { $ this -> checkLocale ( ) ; if ( isset ( $ this -> locales [ $ this -> selectLocale ] [ 'code' ] ) ) { $ code = $ this -> locales [ $ this -> selectLocale ] [ 'code' ] ; return ( $ upper ? strtoupper ( $ code ) : $ code ) ; } return '' ; }
Get code .
12,769
public function setCode ( string $ code ) { if ( $ code ) { $ this -> selectLocale = strtolower ( $ code ) ; $ this -> ready = true ; $ this -> checkLocale ( ) ; } }
Set code .
12,770
public function getCodeDefault ( bool $ upper = false ) : string { return ( $ upper ? strtoupper ( $ this -> defaultLocale ) : $ this -> defaultLocale ) ; }
Get code default .
12,771
public function getIdByCode ( string $ code ) : int { if ( isset ( $ this -> locales [ $ code ] [ 'id' ] ) ) { return $ this -> locales [ $ code ] [ 'id' ] ; } if ( isset ( $ this -> aliasLocale [ $ code ] ) ) { $ this -> locales [ $ this -> aliasLocale [ $ code ] ] [ 'id' ] ; } return ( $ this -> locales [ $ this -> d...
Get id by code .
12,772
public function parseFromString ( $ url ) { $ urlData = parse_url ( $ url ) ; if ( isset ( $ urlData [ 'scheme' ] ) ) { $ this -> scheme = $ urlData [ 'scheme' ] ; } if ( isset ( $ urlData [ 'host' ] ) ) { $ this -> host = $ urlData [ 'host' ] ; } if ( isset ( $ urlData [ 'port' ] ) ) { $ this -> port = $ urlData [ 'po...
Parse URL from the string
12,773
public function addQueryParams ( array $ params ) { foreach ( $ params as $ param => $ value ) { $ this -> setQueryParam ( $ param , $ value ) ; } return $ this ; }
Add parameters to query
12,774
public function isRelative ( ) { if ( $ this -> host === null ) { return true ; } if ( $ this -> host === '/' || $ this -> host === '//' ) { return true ; } return false ; }
Is URL relative ?
12,775
public function assemble ( ) { $ url = $ this -> assembleScheme ( ) ; $ url .= $ this -> assembleIdentification ( ) ; $ url .= $ this -> assembleHost ( ) ; $ url .= $ this -> assemblePath ( ) ; $ url .= $ this -> assembleQuery ( ) ; $ url .= $ this -> assembleFragment ( ) ; return $ url ; }
Assemble the URL
12,776
protected function assembleIdentification ( ) { if ( $ this -> username === null ) { return '' ; } if ( $ this -> password === null ) { return $ this -> username . '@' ; } return $ this -> username . ':' . $ this -> password . '@' ; }
Assemble URL identification
12,777
protected function assembleHost ( ) { if ( $ this -> host === null ) { return '/' ; } if ( $ this -> port === null ) { return $ this -> host ; } return $ this -> host . ':' . $ this -> port ; }
Assemble URL host
12,778
protected function assemblePath ( ) { $ root = $ this -> isRelative ( ) ? '' : '/' ; if ( $ this -> path === null ) { return $ root ; } return $ root . ltrim ( $ this -> path , '/' ) ; }
Assemble URL path
12,779
protected function assembleQuery ( ) { if ( empty ( $ this -> query ) ) { if ( $ this -> queryRaw === null ) { return '' ; } return $ this -> queryRaw ; } return '?' . http_build_query ( $ this -> query ) ; }
Assemble URL query
12,780
public function setTimeZone ( $ timezone ) { $ this -> timezone = ( $ timezone instanceof \ DateTimeZone ) ? $ timezone : new \ DateTimeZone ( $ timezone ) ; return $ this ; }
Set global time zone
12,781
public function format ( $ dateTime , $ format = null , $ timezone = null ) { $ format = preg_replace ( '/(^|[^\\\])D/' , "\\1" . self :: DAY_ABBR , $ format ) ; $ format = preg_replace ( '/(^|[^\\\])l/' , "\\1" . self :: DAY_NAME , $ format ) ; $ format = preg_replace ( '/(^|[^\\\])M/' , "\\1" . self :: MONTH_ABBR , $...
Format to string
12,782
public function actionDelete ( $ id ) { $ this -> trigger ( self :: EVENT_BEFORE_DELETE_CATEGORY ) ; $ category = Category :: findOne ( $ id ) ; if ( ( $ category -> delete ( ) ) ) { Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , 'The category has been successfully removed' ) ; if ( \ Yii :: $ app -> request ...
Deletes one category by id
12,783
public function actionAddImages ( int $ categoryId , int $ languageId ) { $ this -> trigger ( self :: EVENT_BEFORE_EDIT_CATEGORY ) ; $ category = Category :: findOne ( $ categoryId ) ; $ image_form = new CategoryImageForm ( ) ; if ( Yii :: $ app -> request -> isPost ) { $ image_form -> cover = UploadedFile :: getInstan...
Adds category images
12,784
public function actionDeleteImage ( int $ id , string $ imageType ) { $ this -> trigger ( self :: EVENT_BEFORE_EDIT_CATEGORY , new CategoryEvent ( ) ) ; $ category = Category :: findOne ( $ id ) ; if ( \ Yii :: $ app -> shop_imagable -> delete ( 'shop-category/' . $ imageType , $ category -> $ imageType ) ) { $ categor...
Deletes one image from category
12,785
public function actionSelectFilters ( int $ categoryId , int $ languageId , $ id = null ) { $ category = Category :: findOne ( $ categoryId ) ; if ( empty ( $ category ) ) throw new NotFoundHttpException ( ) ; $ filters = Filter :: find ( ) -> where ( [ 'category_id' => $ category -> id ] ) -> all ( ) ; $ filter = ( ! ...
Selects product filters for category
12,786
public function actionDeleteFilter ( int $ id ) { $ filter = Filter :: findOne ( $ id ) ; $ filter -> delete ( ) ; $ this -> trigger ( self :: EVENT_AFTER_EDIT_CATEGORY , new CategoryEvent ( [ 'id' => $ filter -> category_id ] ) ) ; return $ this -> redirect ( Yii :: $ app -> request -> referrer ) ; }
Deletes product filter from category
12,787
public function actionUp ( $ id ) { if ( $ category = Category :: findOne ( $ id ) ) { $ this -> trigger ( self :: EVENT_BEFORE_EDIT_CATEGORY ) ; if ( $ category -> movePrev ( ) ) { $ this -> trigger ( self :: EVENT_AFTER_EDIT_CATEGORY , new CategoryEvent ( [ 'id' => $ id ] ) ) ; if ( \ Yii :: $ app -> request -> isAja...
Changes category position to up
12,788
public function actionSwitchShow ( $ id ) { $ category = Category :: findOne ( $ id ) ; if ( ! empty ( $ category ) ) { $ this -> trigger ( self :: EVENT_BEFORE_EDIT_CATEGORY ) ; $ category -> show = ! $ category -> show ; $ category -> save ( ) ; $ this -> trigger ( self :: EVENT_AFTER_EDIT_CATEGORY , new CategoryEven...
Shows or hides category
12,789
public function filterModelCollectionAsContainer ( Collection $ collection ) { parent :: filterModelCollectionAsContainer ( $ collection ) ; $ collection -> filter ( new Equals ( "Accepted" , false ) ) ; }
Override to filter a model collection to apply any necessary filters only when this is the REST collection of the specific resource being fetched
12,790
public function addGlobal ( $ name , $ value ) { $ this -> createTwig ( ) ; $ this -> twig -> addGlobal ( $ name , $ value ) ; }
Registers a Global
12,791
public function display ( $ view , $ params = [ ] ) { $ CI = & get_instance ( ) ; $ CI -> output -> set_output ( $ this -> render ( $ view , $ params ) ) ; }
Renders Twig Template and Set Output
12,792
public function render ( $ view , $ params = [ ] ) { $ this -> createTwig ( ) ; $ this -> addFunctions ( ) ; $ view = $ view . '.twig' ; return $ this -> twig -> render ( $ view , $ params ) ; }
Renders Twig Template and Returns as String
12,793
private function getOriginalValues ( $ input , $ for_update ) { $ this -> full_pk = false ; $ this -> loadPk ( $ input ) ; if ( $ this -> full_pk ) { $ temp = $ this -> loadValues ( $ for_update ) ; if ( $ temp !== false ) { $ this -> original_values = $ temp ; $ this -> values_loaded = true ; } } }
Get original values
12,794
public function sortFieldsForProcessing ( $ fields , $ options = [ ] ) { if ( ! empty ( $ this -> collection_object ) ) { $ collection = array_key_get ( $ this -> collection_object -> data , $ options [ 'details_collection_key' ] ?? null ) ; foreach ( $ fields as $ k => $ v ) { if ( $ k == $ this :: SEPARATOR_HORIZONTA...
Sort fields for processing
12,795
public function validateRequiredOneField ( & $ value , $ error_name , $ options ) { if ( $ this -> hasErrors ( $ error_name ) ) return ; if ( isset ( $ options [ 'options' ] [ 'required' ] ) && ( $ options [ 'options' ] [ 'required' ] === true || ( $ options [ 'options' ] [ 'required' ] . '' ) === '1' ) ) { if ( $ opti...
Validate required one field
12,796
public function parentKeysToErrorName ( $ parent_keys ) { $ result = [ ] ; if ( ! is_array ( $ parent_keys ) ) { $ parent_keys = [ $ parent_keys ] ; } foreach ( $ parent_keys as $ v ) { if ( empty ( $ result ) ) { $ result [ ] = $ v ; } else { $ result [ ] = '[' . $ v . ']' ; } } return implode ( '' , $ result ) ; }
Convert parent keys to error name
12,797
public function generateMultipleColumns ( $ value , $ error_name , $ values , $ parent_keys , $ options = [ ] ) { if ( ! empty ( $ value ) ) { if ( ! is_array ( $ value ) ) { $ value = [ $ value ] ; } $ result = [ ] ; $ fields_key_holder = [ ] ; $ this -> generateDetailsPrimaryKey ( $ fields_key_holder , 'reset' , $ va...
Generate values for multiple columns
12,798
public function processListQueryOrderBy ( ) { if ( ! empty ( $ this -> values [ '\Object\Form\Model\Dummy\Sort' ] ) ) { foreach ( $ this -> values [ '\Object\Form\Model\Dummy\Sort' ] as $ k => $ v ) { if ( ! empty ( $ v [ '__sort' ] ) ) { $ name = $ this -> detail_fields [ '\Object\Form\Model\Dummy\Sort' ] [ 'elements'...
Process list query order by clause
12,799
private function convertMultipleColumns ( & $ values ) { foreach ( $ this -> fields as $ k => $ v ) { if ( ! empty ( $ v [ 'options' ] [ 'multiple_column' ] ) ) { if ( ! empty ( $ values [ $ k ] ) ) { pk ( $ v [ 'options' ] [ 'multiple_column' ] , $ values [ $ k ] ) ; $ values [ $ k ] = array_keys ( $ values [ $ k ] ) ...
Convert multiple columns