idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
53,800
private function getPluginConfig ( $ pluginId ) { if ( ! array_key_exists ( static :: CONFIG_KEY , $ this -> installState ) ) { return [ ] ; } if ( ! array_key_exists ( $ pluginId , $ this -> installState [ static :: CONFIG_KEY ] ) ) { return [ ] ; } return $ this -> installState [ static :: CONFIG_KEY ] [ $ pluginId ] ; }
Get plugin config from the install state .
53,801
public function addColumns ( array $ cols ) { foreach ( $ cols as $ col ) { $ this -> cols [ ] = DataColumn :: fromArray ( $ col ) ; } }
Adds multiple columns at the end of the array the column should be an associative array that can have label id and type
53,802
public function addColumn ( $ id , $ label , $ type ) { $ this -> cols [ ] = new DataColumn ( $ id , $ label , $ type ) ; }
Adds a column at the end of the DataTable
53,803
public function getLabels ( ) { $ labels = array ( ) ; foreach ( $ this -> cols as $ col ) { $ labels [ ] = $ col -> getLabel ( ) ; } return $ labels ; }
Returns all the column labels
53,804
public function getValuesForPosition ( $ pos ) { $ arr = array ( ) ; foreach ( $ this -> rows as $ key => $ row ) { $ arr [ $ key ] = $ row -> getValueForPosition ( $ pos ) ; } return $ arr ; }
Returns an array that contains the values for a specific column
53,805
public function execute ( QueueInterface $ queue , Message $ message ) : bool { $ service = $ this -> objectManager -> get ( $ this -> className ) ; $ this -> deferMethodCallAspect -> setProcessingJob ( true ) ; try { $ methodName = $ this -> methodName ; call_user_func_array ( [ $ service , $ methodName ] , $ this -> arguments ) ; return true ; } catch ( \ Exception $ exception ) { throw $ exception ; } finally { $ this -> deferMethodCallAspect -> setProcessingJob ( false ) ; } }
Execute the job
53,806
public static function definePrestoThemeAsDefault ( ) { Drupal :: configFactory ( ) -> getEditable ( 'system.theme' ) -> set ( 'default' , 'presto_theme' ) -> save ( ) ; Drupal :: configFactory ( ) -> getEditable ( 'system.theme' ) -> set ( 'admin' , 'seven' ) -> save ( ) ; }
Define Presto Theme as Default . Used by the batch during install process .
53,807
protected static function readConfig ( $ path , $ file ) { $ source = new FileStorage ( $ path ) ; $ configStorage = Drupal :: service ( 'config.storage' ) ; return $ configStorage -> write ( $ file , $ source -> read ( $ file ) ) ; }
Re - read config from file into active storage .
53,808
public function gchartTreeMap ( \ Twig_Environment $ env , $ data , $ id , $ width , $ height , $ title = '' , $ config = array ( ) , $ events = array ( ) ) { return $ this -> renderGChart ( $ env , $ data , $ id , 'TreeMap' , $ width , $ height , $ title , $ config , true , $ events ) ; }
gchart_treemap definition - needs 4 cols
53,809
protected function renderGChart ( \ Twig_Environment $ env , $ data , $ id , $ type , $ width , $ height , $ title = null , $ config = array ( ) , $ addDivWithAndHeight = false , $ events = array ( ) ) { $ config [ 'width' ] = $ width ; $ config [ 'height' ] = $ height ; if ( ! isset ( $ config [ 'title' ] ) && ! is_null ( $ title ) && trim ( $ title ) != '' ) { $ config [ 'title' ] = $ title ; } return $ this -> renderTemplate ( $ env , 'gChartTemplate' , array ( 'chartType' => $ type , 'data' => $ data , 'id' => $ id , 'config' => $ config , 'events' => $ events ) , $ addDivWithAndHeight ) ; }
Generic method that returns html of gchart charts
53,810
protected function renderTemplate ( \ Twig_Environment $ env , $ templateName , $ params , $ addDivWithAndHeight = false ) { $ templ = false ; if ( isset ( $ this -> resources [ $ templateName ] ) ) { $ templ = $ env -> loadTemplate ( $ this -> resources [ $ templateName ] ) ; } else { throw new \ Exception ( 'mmm, template not found' ) ; } if ( $ addDivWithAndHeight && isset ( $ params [ 'config' ] ) && isset ( $ params [ 'config' ] [ 'width' ] ) && isset ( $ params [ 'config' ] [ 'height' ] ) ) { $ params [ 'addDivWithAndHeight' ] = true ; $ params [ 'width' ] = $ params [ 'config' ] [ 'width' ] ; $ params [ 'height' ] = $ params [ 'config' ] [ 'height' ] ; } else { $ params [ 'addDivWithAndHeight' ] = false ; } return $ templ -> render ( $ params ) ; }
generic method that generates a Twig template based on its name
53,811
protected function loadAttributeValue ( $ name , $ attribute ) { $ query = Drupal :: entityQuery ( 'commerce_product_attribute_value' ) ; $ result = $ query -> condition ( 'name' , $ name ) -> condition ( 'attribute' , $ attribute ) -> execute ( ) ; $ attributeValue = NULL ; if ( count ( $ result ) > 0 ) { $ attributeValue = ProductAttributeValue :: load ( reset ( $ result ) ) ; } return $ attributeValue ; }
Loads a product attribute value by attribute ID and name .
53,812
public static function fromArray ( array $ arr ) { $ v = isset ( $ arr [ 'v' ] ) ? $ arr [ 'v' ] : null ; $ f = isset ( $ arr [ 'f' ] ) ? $ arr [ 'f' ] : null ; $ p = isset ( $ arr [ 'p' ] ) ? $ arr [ 'p' ] : null ; return new DataCell ( $ v , $ f , $ p ) ; }
Create an instance of DataCell from an array .
53,813
public function call ( $ procedure , $ varArgs = null ) { if ( ! is_string ( $ procedure ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s requires a string at Argument 1' , __METHOD__ ) ) ; } if ( ! $ this -> isStarted ) { $ this -> start ( ) ; } if ( $ this -> maxTaskQueueSize < 0 || $ this -> maxTaskQueueSize > $ this -> outstandingTaskCount ) { $ task = $ this -> taskReflection -> newInstanceArgs ( func_get_args ( ) ) ; return $ this -> acceptNewTask ( $ task ) ; } else { return new Failure ( new TooBusyException ( sprintf ( "Cannot execute '%s' task; too busy" , $ procedure ) ) ) ; } }
Dispatch a procedure call to the thread pool
53,814
public function execute ( \ Stackable $ task ) { if ( ! $ this -> isStarted ) { $ this -> start ( ) ; } if ( $ this -> maxTaskQueueSize < 0 || $ this -> maxTaskQueueSize > $ this -> outstandingTaskCount ) { return $ this -> acceptNewTask ( $ task ) ; } else { return new Failure ( new TooBusyException ( sprintf ( 'Cannot execute task of type %s; too busy' , get_class ( $ task ) ) ) ) ; } }
Dispatch a pthreads Stackable to the thread pool for processing
53,815
public function start ( ) { if ( ! $ this -> isStarted ) { $ this -> generateIpcServer ( ) ; $ this -> isStarted = true ; for ( $ i = 0 ; $ i < $ this -> poolSizeMin ; $ i ++ ) { $ this -> spawnWorker ( ) ; } $ this -> registerTaskTimeoutWatcher ( ) ; } return $ this ; }
Spawn worker threads
53,816
public function setOption ( $ option , $ value ) { switch ( $ option ) { case self :: OPT_THREAD_FLAGS : $ this -> setThreadStartFlags ( $ value ) ; break ; case self :: OPT_POOL_SIZE_MIN : $ this -> setPoolSizeMin ( $ value ) ; break ; case self :: OPT_POOL_SIZE_MAX : $ this -> setPoolSizeMax ( $ value ) ; break ; case self :: OPT_TASK_TIMEOUT : $ this -> setTaskTimeout ( $ value ) ; break ; case self :: OPT_IDLE_WORKER_TIMEOUT : $ this -> setIdleWorkerTimeout ( $ value ) ; break ; case self :: OPT_EXEC_LIMIT : $ this -> setExecutionLimit ( $ value ) ; break ; case self :: OPT_IPC_URI : $ this -> setIpcUri ( $ value ) ; break ; case self :: OPT_UNIX_IPC_DIR : $ this -> setUnixIpcSocketDir ( $ value ) ; break ; default : throw new \ DomainException ( sprintf ( 'Unknown option: %s' , $ option ) ) ; } return $ this ; }
Configure dispatcher options
53,817
public function removeStartTask ( \ Stackable $ task ) { if ( $ this -> workerStartTasks -> contains ( $ task ) ) { $ this -> workerStartTasks -> detach ( $ task ) ; } }
Clear a worker task currently stored for execution each time a worker spawns
53,818
public function cleanup ( ) { if ( ! $ this -> memory ) { throw new \ LogicException ( "Cleanup should be used after allocate." ) ; } $ this -> memory -> delete ( ) ; $ this -> memory = null ; }
Method to be called when the adapter is finished with .
53,819
protected function setOptionsOnRequest ( CurlRequest $ request , $ options ) { foreach ( $ options as $ option => $ value ) { $ request -> setOption ( $ option , $ value ) ; } }
Set the defined options on the given CurlRequest instance
53,820
public function updateCMSFields ( FieldList $ fields ) { $ gridField = GridField :: create ( 'CarouselItems' , _t ( __CLASS__ . 'TITLE' , 'Hero/Carousel' ) , $ this -> getCarouselItems ( ) , GridFieldConfig_RelationEditor :: create ( ) ) ; $ gridField -> setDescription ( _t ( __CLASS__ . 'NOTE' , 'NOTE: Carousel functionality will automatically be loaded when 2 or more items are added below' ) ) ; $ gridConfig = $ gridField -> getConfig ( ) ; $ gridConfig -> getComponentByType ( GridFieldAddNewButton :: class ) -> setButtonName ( _t ( __CLASS__ . 'ADDNEW' , 'Add new' ) ) ; $ gridConfig -> removeComponentsByType ( GridFieldAddExistingAutocompleter :: class ) ; $ gridConfig -> removeComponentsByType ( GridFieldDeleteAction :: class ) ; $ gridConfig -> addComponent ( new GridFieldDeleteAction ( ) ) ; $ gridConfig -> addComponent ( new GridFieldOrderableRows ( 'SortOrder' ) ) ; $ gridConfig -> removeComponentsByType ( GridFieldSortableHeader :: class ) ; $ gridField -> setModelClass ( CarouselItem :: class ) ; $ fields -> findOrMakeTab ( 'Root.Carousel' , _t ( __CLASS__ . 'TITLE' , 'Hero/Carousel' ) ) ; $ fields -> addFieldToTab ( 'Root.Carousel' , $ gridField ) ; }
Add the carousel management GridField to the Page s CMS fields
53,821
protected function processRawResponse ( $ rawResult ) { $ result = json_decode ( $ rawResult , TRUE ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new RuntimeException ( 'Malformed JSON response! Message: ' . json_last_error_msg ( ) ) ; } return $ result ; }
Process the raw JSON response given from conduit . Throw an exception when given JSON is malformed
53,822
private function waitForAnyThread ( ) { while ( true ) { foreach ( $ this -> getPIDs ( ) as $ pid ) { if ( ! $ this -> isRunning ( $ pid ) ) { return ; } } sleep ( 1 ) ; } }
If we ve exhausted our limit of threads wait for one to finish .
53,823
public function initialize ( ) { $ this -> handler = curl_init ( ) ; $ this -> setOption ( CURLOPT_URL , $ this -> requestUrl ) -> setOption ( CURLOPT_VERBOSE , 0 ) -> setOption ( CURLOPT_HEADER , 0 ) ; }
Initialize the CURL session
53,824
public function setOption ( $ option , $ value ) { $ res = @ curl_setopt ( $ this -> handler , $ option , $ value ) ; if ( $ res === TRUE ) { return $ this ; } throw new RuntimeException ( 'Failed to set the following option: ' . $ option ) ; }
Set an opt in current curl handler
53,825
public function setOptionFromArray ( $ options ) { foreach ( $ options as $ option => $ value ) { $ this -> setOption ( $ option , $ value ) ; } return $ this ; }
Set multiple options with an associative array
53,826
public function execute ( $ returnTransfer = TRUE ) { if ( $ returnTransfer === TRUE ) { $ this -> setOption ( CURLOPT_RETURNTRANSFER , 1 ) ; } $ result = curl_exec ( $ this -> handler ) ; if ( curl_errno ( $ this -> handler ) ) { $ format = [ curl_errno ( $ this -> handler ) , curl_error ( $ this -> handler ) ] ; $ this -> close ( ) ; throw RuntimeException :: createByFormat ( 'Error executing request, error code: %s, Message: %s' , $ format ) ; } return $ result ; }
Execute the prepared request and optionally returns the response
53,827
public function pushEndpointHandler ( $ apiName , $ handlerClassName ) { if ( ! class_exists ( $ handlerClassName ) ) { throw new RuntimeException ( 'This handler class (' . $ handlerClassName . ') not found!' ) ; } $ apiName = ucfirst ( strtolower ( $ apiName ) ) ; $ this -> uniqueEndpointHandlers [ $ apiName ] = $ handlerClassName ; if ( isset ( $ this -> endpointObjectCache [ $ apiName ] ) ) { unset ( $ this -> endpointObjectCache [ $ apiName ] ) ; } }
Pushes a unique handler to the stack . Unique handlers are preferred over default handlers . One endpoint only have on unique handler and if you push another it will overwrite the previous
53,828
protected function getEndpointHandler ( $ apiName , ReflectionClass $ endpointReflector ) { if ( isset ( $ this -> endpointObjectCache [ $ apiName ] ) ) { return $ this -> endpointObjectCache [ $ apiName ] ; } $ endpointInstance = $ endpointReflector -> newInstanceArgs ( [ $ this -> getClient ( ) ] ) ; $ this -> endpointObjectCache [ $ apiName ] = $ endpointInstance ; return $ endpointInstance ; }
Returns a new instance from the given endpoint handler . In the instance creation the client is passed to tha handler as parameter .
53,829
protected function getExecutorMethod ( $ methodName , ReflectionClass $ endpointReflector ) { $ neededMethod = strtolower ( $ methodName ) . "Executor" ; if ( ! $ endpointReflector -> hasMethod ( $ neededMethod ) ) { $ neededMethod = "defaultExecutor" ; } return $ endpointReflector -> getMethod ( $ neededMethod ) ; }
Return the reflector of the method that can execute the query on the endpoint .
53,830
protected function getHandlerClassName ( $ apiName ) { $ apiName = ucfirst ( strtolower ( $ apiName ) ) ; $ neededClass = __NAMESPACE__ . '\\' . 'Endpoints\\Defaults\\' . $ apiName ; if ( isset ( $ this -> uniqueEndpointHandlers [ $ apiName ] ) ) { $ neededClass = $ this -> uniqueEndpointHandlers [ $ apiName ] ; } return $ neededClass ; }
Returns the FQCN of the handler class . Returns the default handler if no unique handler available for the given endpoint .
53,831
private function getMemory ( ) { $ memory = shmop_open ( $ this -> key , "c" , 0644 , self :: LIMIT ) ; if ( ! $ memory ) { throw new Exception ( "Unable to open the shared memory block" ) ; } return $ memory ; }
Get the shared memory segment .
53,832
private function unserialize ( $ memory ) : array { $ data = shmop_read ( $ memory , 0 , self :: LIMIT ) ; $ exceptions = unserialize ( $ data ) ; if ( ! is_array ( $ exceptions ) ) { $ exceptions = [ ] ; } return $ exceptions ; }
Get the exception details out of shared memory .
53,833
public function addException ( \ Throwable $ exception ) { $ memory = $ this -> getMemory ( ) ; $ exceptions = $ this -> unserialize ( $ memory ) ; $ exceptions [ ] = get_class ( $ exception ) . ": " . $ exception -> getMessage ( ) . " (" . $ exception -> getFile ( ) . ":" . $ exception -> getLine ( ) . ")" ; $ data = serialize ( $ exceptions ) ; shmop_write ( $ memory , $ data , 0 ) ; shmop_close ( $ memory ) ; }
Add an exception the shared memory .
53,834
public function getExceptions ( ) : array { $ memory = $ this -> getMemory ( ) ; $ exceptions = $ this -> unserialize ( $ memory ) ; shmop_write ( $ memory , serialize ( [ ] ) , 0 ) ; shmop_close ( $ memory ) ; return $ exceptions ; }
Get all the exceptions added to the shared memory .
53,835
public function delete ( ) { $ memory = shmop_open ( $ this -> key , "a" , 0 , 0 ) ; if ( $ memory ) { shmop_delete ( $ memory ) ; shmop_close ( $ memory ) ; } }
Delete the shared memory this instance represents .
53,836
protected function addSearchOptions ( FieldList $ fields ) { $ fields -> findOrMakeTab ( 'Root.SearchOptions' ) ; $ fields -> addFieldToTab ( 'Root.SearchOptions' , TextField :: create ( 'EmptySearch' , _t ( 'CWP.SITECONFIG.EmptySearch' , 'Text to display when there is no search query' ) ) ) ; $ fields -> addFieldToTab ( 'Root.SearchOptions' , TextField :: create ( 'NoSearchResults' , _t ( 'CWP.SITECONFIG.NoResult' , 'Text to display when there are no results' ) ) ) ; return $ this ; }
Add user configurable search field labels
53,837
protected function addThemeColorPicker ( FieldList $ fields ) { if ( ! $ this -> owner -> config ( ) -> get ( 'enable_theme_color_picker' ) ) { return $ this ; } $ fonts = $ this -> owner -> config ( ) -> get ( 'theme_fonts' ) ; foreach ( $ fonts as $ fontTitle ) { $ fontFamilyName = str_replace ( ' ' , '+' , $ fontTitle ) ; Requirements :: css ( "//fonts.googleapis.com/css?family=$fontFamilyName" ) ; } $ fields -> addFieldsToTab ( 'Root.ThemeOptions' , [ FontPickerField :: create ( 'MainFontFamily' , _t ( __CLASS__ . '.MainFontFamily' , 'Main font family' ) , $ fonts ) , ColorPickerField :: create ( 'HeaderBackground' , _t ( __CLASS__ . '.HeaderBackground' , 'Header background' ) , $ this -> getThemeOptionsExcluding ( [ 'default-accent' , ] ) ) , ColorPickerField :: create ( 'NavigationBarBackground' , _t ( __CLASS__ . '.NavigationBarBackground' , 'Navigation bar background' ) , $ this -> getThemeOptionsExcluding ( [ 'default-accent' , ] ) ) , ColorPickerField :: create ( 'CarouselBackground' , _t ( __CLASS__ . '.CarouselBackground' , 'Carousel background' ) , $ this -> getThemeOptionsExcluding ( [ 'default-accent' , ] ) ) -> setDescription ( _t ( __CLASS__ . '.CarouselBackgroundDescription' , 'The background colour of the carousel when there is no image set.' ) ) , ColorPickerField :: create ( 'FooterBackground' , _t ( __CLASS__ . '.FooterBackground' , 'Footer background' ) , $ this -> getThemeOptionsExcluding ( [ 'light-grey' , 'white' , 'default-accent' , ] ) ) , ColorPickerField :: create ( 'AccentColor' , _t ( __CLASS__ . '.AccentColor' , 'Accent colour' ) , $ this -> getThemeOptionsExcluding ( [ 'light-grey' , 'white' , 'default-background' , ] ) ) -> setDescription ( _t ( __CLASS__ . '.AccentColorDescription' , 'Affects colour of buttons, current navigation items, etc. ' . 'Please ensure sufficient contrast with background colours.' ) ) , ColorPickerField :: create ( 'TextLinkColor' , _t ( __CLASS__ . '.TextLinkColor' , 'Text link colour' ) , $ this -> getThemeOptionsExcluding ( [ 'black' , 'light-grey' , 'dark-grey' , 'white' , 'default-background' , ] ) ) , ] ) ; return $ this ; }
Add fields for selecting the font theme colour for different areas of the site .
53,838
public function getThemeOptionsExcluding ( $ excludedColors = [ ] ) { $ themeColors = $ this -> owner -> config ( ) -> get ( 'theme_colors' ) ; $ options = [ ] ; foreach ( $ themeColors as $ themeColor ) { if ( in_array ( $ themeColor [ 'CSSClass' ] , $ excludedColors ) ) { continue ; } $ options [ ] = $ themeColor ; } return $ options ; }
Returns theme_colors used for ColorPickerField .
53,839
protected function extractValueObjects ( SearchResult $ searchResult ) { return array_map ( function ( SearchHit $ searchHit ) { return $ searchHit -> valueObject ; } , $ searchResult -> searchHits ) ; }
Extracts value objects from SearchResult .
53,840
public static function exec ( $ url , array $ req = [ ] ) { usleep ( 120000 ) ; $ postData = http_build_query ( $ req , '' , '&' ) ; if ( is_null ( self :: $ ch ) ) { self :: $ ch = curl_init ( ) ; curl_setopt ( self :: $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( self :: $ ch , CURLOPT_USERAGENT , 'Mozilla/4.0 (compatible; CoinMarketCap PHP API; ' . php_uname ( 'a' ) . '; PHP/' . phpversion ( ) . ')' ) ; } curl_setopt ( self :: $ ch , CURLOPT_URL , $ url . "?" . $ postData ) ; curl_setopt ( self :: $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; $ res = curl_exec ( self :: $ ch ) ; if ( $ res === false ) { throw new \ Exception ( "Curl error: " . curl_error ( self :: $ ch ) ) ; } $ json = json_decode ( $ res , true ) ; if ( isset ( $ json [ 'error' ] ) ) { throw new \ Exception ( "CoinMarketCap API error: {$json['error']}" ) ; } return $ json ; }
Executes curl request to the CoinMarketCap API .
53,841
public static function json ( $ url ) { $ opts = [ 'http' => [ 'method' => 'GET' , 'timeout' => 10 ] ] ; $ context = stream_context_create ( $ opts ) ; $ feed = file_get_contents ( $ url , false , $ context ) ; $ json = json_decode ( $ feed , true ) ; return $ json ; }
Executes simple GET request to the CoinMarketCap public API .
53,842
public function mapContent ( VersionInfo $ versionInfo , $ languageCode ) { $ contentInfo = $ versionInfo -> contentInfo ; return new Content ( [ 'id' => $ contentInfo -> id , 'mainLocationId' => $ contentInfo -> mainLocationId , 'name' => $ versionInfo -> getName ( $ languageCode ) , 'languageCode' => $ languageCode , 'innerVersionInfo' => $ versionInfo , 'site' => $ this -> site , 'domainObjectMapper' => $ this , 'repository' => $ this -> repository , ] ) ; }
Maps Repository Content to the Site Content .
53,843
public function mapContentInfo ( VersionInfo $ versionInfo , $ languageCode ) { $ contentInfo = $ versionInfo -> contentInfo ; $ contentType = $ this -> contentTypeService -> loadContentType ( $ contentInfo -> contentTypeId ) ; return new ContentInfo ( [ 'name' => $ versionInfo -> getName ( $ languageCode ) , 'languageCode' => $ languageCode , 'contentTypeIdentifier' => $ contentType -> identifier , 'contentTypeName' => $ this -> getTranslatedString ( $ languageCode , ( array ) $ contentType -> getNames ( ) ) , 'contentTypeDescription' => $ this -> getTranslatedString ( $ languageCode , ( array ) $ contentType -> getDescriptions ( ) ) , 'innerContentInfo' => $ versionInfo -> contentInfo , 'innerContentType' => $ contentType , 'site' => $ this -> site , ] ) ; }
Maps Repository ContentInfo to the Site ContentInfo .
53,844
public function mapLocation ( APILocation $ location , VersionInfo $ versionInfo , $ languageCode ) { return new Location ( [ 'innerLocation' => $ location , 'languageCode' => $ languageCode , 'innerVersionInfo' => $ versionInfo , 'site' => $ this -> site , 'domainObjectMapper' => $ this , ] ) ; }
Maps Repository Location to the Site Location .
53,845
public function mapNode ( APILocation $ location , APIContent $ content , $ languageCode ) { return new Node ( [ 'contentInfo' => $ this -> mapContentInfo ( $ content -> versionInfo , $ languageCode ) , 'innerLocation' => $ location , 'content' => $ this -> mapContent ( $ content -> versionInfo , $ languageCode ) , 'site' => $ this -> site , ] ) ; }
Maps Repository Content and Location to the Site Node .
53,846
public function mapField ( APIField $ apiField , SiteContent $ content ) { $ fieldDefinition = $ content -> contentInfo -> innerContentType -> getFieldDefinition ( $ apiField -> fieldDefIdentifier ) ; $ fieldTypeIdentifier = $ fieldDefinition -> fieldTypeIdentifier ; $ isEmpty = $ this -> fieldTypeService -> getFieldType ( $ fieldTypeIdentifier ) -> isEmptyValue ( $ apiField -> value ) ; return new Field ( [ 'id' => $ apiField -> id , 'fieldDefIdentifier' => $ fieldDefinition -> identifier , 'value' => $ apiField -> value , 'languageCode' => $ apiField -> languageCode , 'fieldTypeIdentifier' => $ fieldTypeIdentifier , 'name' => $ this -> getTranslatedString ( $ content -> languageCode , ( array ) $ fieldDefinition -> getNames ( ) ) , 'description' => $ this -> getTranslatedString ( $ content -> languageCode , ( array ) $ fieldDefinition -> getDescriptions ( ) ) , 'content' => $ content , 'innerField' => $ apiField , 'innerFieldDefinition' => $ fieldDefinition , 'isEmpty' => $ isEmpty , ] ) ; }
Maps Repository Field to the Site Field .
53,847
public function getFacets ( ) { if ( isset ( $ this -> facets ) ) { return $ this -> facets ; } return $ this -> facets = $ this -> getSearchResultWithLimitZero ( ) -> facets ; }
Returns the facets of the results .
53,848
public function getSlice ( $ offset , $ length ) { $ query = clone $ this -> query ; $ query -> offset = $ offset ; $ query -> limit = $ length ; $ query -> performCount = false ; $ searchResult = $ this -> filterService -> filterLocations ( $ query ) ; if ( ! isset ( $ this -> nbResults ) && isset ( $ searchResult -> totalCount ) ) { $ this -> nbResults = $ searchResult -> totalCount ; } if ( ! isset ( $ this -> facets ) && isset ( $ searchResult -> facets ) ) { $ this -> facets = $ searchResult -> facets ; } $ list = [ ] ; foreach ( $ searchResult -> searchHits as $ hit ) { $ list [ ] = $ hit -> valueObject ; } return $ list ; }
Returns a slice of the results as Site Location objects .
53,849
protected function injectSiteApiValueObjects ( Request $ request , $ language ) { $ content = $ request -> attributes -> get ( 'content' ) ; $ location = $ request -> attributes -> get ( 'location' ) ; $ siteContent = $ this -> loadService -> loadContent ( $ content -> id , $ content -> versionInfo -> versionNo , $ language ) ; if ( ! $ location -> isDraft ( ) ) { $ siteLocation = $ this -> loadService -> loadLocation ( $ location -> id ) ; } else { $ siteLocation = new SiteLocation ( [ 'contentInfo' => $ siteContent -> contentInfo , 'innerLocation' => $ location , ] ) ; } $ requestParams = $ request -> attributes -> get ( 'params' ) ; $ requestParams [ 'content' ] = $ siteContent ; $ requestParams [ 'location' ] = $ siteLocation ; $ request -> attributes -> set ( 'content' , $ siteContent ) ; $ request -> attributes -> set ( 'location' , $ siteLocation ) ; $ request -> attributes -> set ( 'params' , $ requestParams ) ; }
Injects the Site API value objects into request replacing the original eZ API value objects .
53,850
protected function isLegacyModeSiteAccess ( $ siteAccessName ) { if ( ! $ this -> configResolver -> hasParameter ( 'legacy_mode' , 'ezsettings' , $ siteAccessName ) ) { return false ; } return $ this -> configResolver -> getParameter ( 'legacy_mode' , 'ezsettings' , $ siteAccessName ) ; }
Returns if the provided siteaccess is running in legacy mode .
53,851
protected function register_default_types ( ) { require_once "{$this->dir}/includes/fontpack.php" ; Icon_Picker_Fontpack :: instance ( ) ; $ default_types = array_filter ( ( array ) apply_filters ( 'icon_picker_default_types' , $ this -> default_types ) ) ; $ default_types = array_intersect ( $ this -> default_types , $ default_types ) ; if ( empty ( $ default_types ) ) { return ; } foreach ( $ default_types as $ filename => $ class_suffix ) { $ class_name = "Icon_Picker_Type_{$class_suffix}" ; require_once "{$this->dir}/includes/types/{$filename}.php" ; $ this -> registry -> add ( new $ class_name ( ) ) ; } }
Register default icon types
53,852
public function load ( ) { if ( true === $ this -> is_admin_loaded ) { return ; } $ this -> loader -> load ( ) ; $ this -> is_admin_loaded = true ; }
Load icon picker functionality on an admin page
53,853
private function buildDefinition ( $ name , $ target , $ operator , $ value ) { return new CriterionDefinition ( [ 'name' => $ name , 'target' => $ target , 'operator' => $ this -> resolveOperator ( $ operator , $ value ) , 'value' => $ value , ] ) ; }
Return CriterionDefinition instance from the given arguments .
53,854
private function resolveOperator ( $ symbol , $ value ) { if ( null === $ symbol ) { return $ this -> getOperatorByValueType ( $ value ) ; } return self :: $ operatorMap [ $ symbol ] ; }
Resolve actual operator value from the given arguments .
53,855
private function validateUser ( UserInterface $ user ) { return $ user -> isValid ( $ this -> username , $ this -> password , $ this -> realm ) ; }
Checks for valid user
53,856
private function getDirective ( ) { switch ( strtolower ( $ this -> type ) ) { case 'digest' : return 'Digest ' . $ this -> buildDirectiveParameters ( array ( 'realm' => $ this -> realm , 'qop' => 'auth' , 'nonce' => uniqid ( ) , 'opaque' => md5 ( $ this -> realm ) , ) ) ; default : return 'Basic ' . $ this -> buildDirectiveParameters ( array ( 'realm' => $ this -> realm ) ) ; } }
Return Directive according the auth type
53,857
private function buildDirectiveParameters ( $ parameters = array ( ) ) { $ result = array ( ) ; foreach ( $ parameters as $ key => $ value ) { $ result [ ] = $ key . '="' . $ value . '"' ; } return implode ( ',' , $ result ) ; }
Format given parameters
53,858
public function getDigest ( ) { $ digest = null ; if ( isset ( $ _SERVER [ 'PHP_AUTH_DIGEST' ] ) ) { $ digest = $ _SERVER [ 'PHP_AUTH_DIGEST' ] ; } elseif ( isset ( $ _SERVER [ 'HTTP_AUTHORIZATION' ] ) ) { if ( strpos ( strtolower ( $ _SERVER [ 'HTTP_AUTHORIZATION' ] ) , 'digest' ) === 0 ) { $ digest = substr ( $ _SERVER [ 'HTTP_AUTHORIZATION' ] , 7 ) ; } } return $ digest ; }
Fetch digest data from environment information
53,859
private function executeRequest ( & $ ch ) { $ result = curl_exec ( $ ch ) ; if ( ! curl_errno ( $ ch ) ) { $ info = curl_getinfo ( $ ch ) ; curl_close ( $ ch ) ; return new Response ( $ info , $ result ) ; } $ errno = curl_errno ( $ ch ) ; $ error = curl_error ( $ ch ) ; curl_close ( $ ch ) ; throw new DripException ( $ error , $ errno ) ; }
Execute and handle the request result
53,860
public function getGlobal ( $ api_method , $ args = [ ] , $ timeout = 10 ) { $ url = $ this -> api_endpoint . '/' . $ api_method ; return $ this -> makeRequest ( 'get' , $ api_method , $ args , $ timeout , $ url ) ; }
Make a GET request to a top - level method outside of this account
53,861
private function buildQueryDefinition ( array $ configuration , ContentView $ view ) { $ parameters = $ this -> processParameters ( $ configuration [ 'parameters' ] , $ view ) ; $ this -> injectSupportedParameters ( $ parameters , $ configuration [ 'query_type' ] , $ view ) ; return new QueryDefinition ( [ 'name' => $ configuration [ 'query_type' ] , 'parameters' => $ parameters , 'useFilter' => $ this -> parameterProcessor -> process ( $ configuration [ 'use_filter' ] , $ view ) , 'maxPerPage' => $ this -> parameterProcessor -> process ( $ configuration [ 'max_per_page' ] , $ view ) , 'page' => $ this -> parameterProcessor -> process ( $ configuration [ 'page' ] , $ view ) , ] ) ; }
Build QueryDefinition instance from the given arguments .
53,862
private function getRelatedContentItems ( array $ relatedContentIds , array $ contentTypeIdentifiers ) { if ( count ( $ relatedContentIds ) === 0 ) { return [ ] ; } $ criteria = new ContentId ( $ relatedContentIds ) ; if ( ! empty ( $ contentTypeIdentifiers ) ) { $ criteria = new LogicalAnd ( [ $ criteria , new ContentTypeIdentifier ( $ contentTypeIdentifiers ) , ] ) ; } $ query = new Query ( [ 'filter' => $ criteria , 'limit' => count ( $ relatedContentIds ) , ] ) ; $ searchResult = $ this -> site -> getFilterService ( ) -> filterContent ( $ query ) ; $ contentItems = $ this -> extractValueObjects ( $ searchResult ) ; return $ contentItems ; }
Return an array of related Content from the given arguments .
53,863
public function add ( Icon_Picker_Type $ type ) { if ( $ this -> is_valid_type ( $ type ) ) { $ this -> types [ $ type -> id ] = $ type ; } }
Register icon type
53,864
public function get ( $ id ) { if ( isset ( $ this -> types [ $ id ] ) ) { return $ this -> types [ $ id ] ; } return null ; }
Get icon type
53,865
protected function is_valid_type ( Icon_Picker_Type $ type ) { foreach ( array ( 'id' , 'controller' ) as $ var ) { $ value = $ type -> $ var ; if ( empty ( $ value ) ) { trigger_error ( esc_html ( sprintf ( 'Icon Picker: "%s" cannot be empty.' , $ var ) ) ) ; return false ; } } if ( isset ( $ this -> types [ $ type -> id ] ) ) { trigger_error ( esc_html ( sprintf ( 'Icon Picker: Icon type %s is already registered. Please use a different ID.' , $ type -> id ) ) ) ; return false ; } return true ; }
Check if icon type is valid
53,866
public function get_types_for_js ( ) { $ types = array ( ) ; $ names = array ( ) ; foreach ( $ this -> types as $ type ) { $ types [ $ type -> id ] = $ type -> get_props ( ) ; $ names [ $ type -> id ] = $ type -> name ; } array_multisort ( $ names , SORT_ASC , $ types ) ; return $ types ; }
Get all icon types for JS
53,867
public function getSlice ( $ offset , $ length ) { $ query = clone $ this -> query ; $ query -> offset = $ offset ; $ query -> limit = $ length ; $ query -> performCount = false ; $ searchResult = $ this -> filterService -> filterContent ( $ query ) ; if ( null === $ this -> nbResults && null !== $ searchResult -> totalCount ) { $ this -> nbResults = $ searchResult -> totalCount ; } $ list = [ ] ; foreach ( $ searchResult -> searchHits as $ hit ) { $ list [ ] = $ hit -> valueObject ; } return $ list ; }
Returns a slice of the results as Site Content objects .
53,868
protected function get_image_mime_types ( ) { $ mime_types = get_allowed_mime_types ( ) ; foreach ( $ mime_types as $ id => $ type ) { if ( false === strpos ( $ type , 'image/' ) ) { unset ( $ mime_types [ $ id ] ) ; } } $ mime_types = apply_filters ( 'icon_picker_image_mime_types' , $ mime_types ) ; unset ( $ mime_types [ 'svg' ] ) ; return $ mime_types ; }
Get image mime types
53,869
protected function register_assets ( ) { $ icon_picker = Icon_Picker :: instance ( ) ; if ( defined ( 'ICON_PICKER_SCRIPT_DEBUG' ) && ICON_PICKER_SCRIPT_DEBUG ) { $ assets_url = '//localhost:8080' ; $ suffix = '' ; } else { $ assets_url = $ icon_picker -> url ; $ suffix = ( defined ( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' ; } wp_register_script ( 'icon-picker' , "{$assets_url}/js/icon-picker{$suffix}.js" , array ( 'media-views' ) , Icon_Picker :: VERSION , true ) ; $ this -> add_script ( 'icon-picker' ) ; wp_register_style ( 'icon-picker' , "{$icon_picker->url}/css/icon-picker{$suffix}.css" , false , Icon_Picker :: VERSION ) ; $ this -> add_style ( 'icon-picker' ) ; }
Register scripts & styles
53,870
public function load ( ) { if ( ! is_admin ( ) ) { _doing_it_wrong ( __METHOD__ , 'It should only be called on admin pages.' , esc_html ( Icon_Picker :: VERSION ) ) ; return ; } if ( ! did_action ( 'icon_picker_loader_init' ) ) { _doing_it_wrong ( __METHOD__ , sprintf ( 'It should not be called until the %s hook.' , '<code>icon_picker_loader_init</code>' ) , esc_html ( Icon_Picker :: VERSION ) ) ; return ; } add_action ( 'admin_enqueue_scripts' , array ( $ this , '_enqueue_assets' ) ) ; add_action ( 'print_media_templates' , array ( $ this , '_media_templates' ) ) ; }
Load admin functionalities
53,871
public function _enqueue_assets ( ) { $ icon_picker = Icon_Picker :: instance ( ) ; wp_localize_script ( 'icon-picker' , 'iconPicker' , array ( 'types' => $ icon_picker -> registry -> get_types_for_js ( ) , ) ) ; wp_enqueue_media ( ) ; foreach ( $ this -> script_ids as $ script_id ) { wp_enqueue_script ( $ script_id ) ; } foreach ( $ this -> style_ids as $ style_id ) { wp_enqueue_style ( $ style_id ) ; } do_action ( 'icon_picker_admin_loaded' , $ icon_picker ) ; }
Enqueue scripts & styles
53,872
protected function collect_packs ( ) { $ iterator = new DirectoryIterator ( $ this -> dir ) ; foreach ( $ iterator as $ pack_dir ) { if ( $ pack_dir -> isDot ( ) || ! $ pack_dir -> isDir ( ) || ! $ pack_dir -> isReadable ( ) ) { continue ; } $ pack_dirname = $ pack_dir -> getFilename ( ) ; $ pack_data = $ this -> get_pack_data ( $ pack_dir ) ; if ( ! empty ( $ pack_data ) ) { $ this -> packs [ $ pack_dirname ] = $ pack_data ; } } }
Collect icon packs
53,873
protected function register_packs ( ) { if ( empty ( $ this -> packs ) ) { return ; } $ icon_picker = Icon_Picker :: instance ( ) ; require_once "{$icon_picker->dir}/includes/types/fontello.php" ; foreach ( $ this -> packs as $ pack_data ) { $ icon_picker -> registry -> add ( new Icon_Picker_Type_Fontello ( $ pack_data ) ) ; } }
Register icon packs
53,874
protected function get_pack_data ( DirectoryIterator $ pack_dir ) { $ pack_dirname = $ pack_dir -> getFilename ( ) ; $ pack_path = $ pack_dir -> getPathname ( ) ; $ cache_id = "icon_picker_fontpack_{$pack_dirname}" ; $ cache_data = get_transient ( $ cache_id ) ; $ config_file = "{$pack_path}/config.json" ; if ( false !== $ cache_data && $ cache_data [ 'version' ] === $ pack_dir -> getMTime ( ) ) { return $ cache_data ; } if ( ! is_readable ( $ config_file ) ) { trigger_error ( sprintf ( esc_html ( $ this -> messages [ 'no_config' ] ) , '<code>config.json</code>' , sprintf ( '<code>%s</code>' , esc_html ( $ pack_path ) ) ) ) ; return false ; } $ config = json_decode ( file_get_contents ( $ config_file ) , true ) ; $ errors = json_last_error ( ) ; if ( ! empty ( $ errors ) ) { trigger_error ( sprintf ( esc_html ( $ this -> messages [ 'config_error' ] ) , sprintf ( '<code>%s/config.json</code>' , esc_html ( $ pack_path ) ) ) ) ; return false ; } $ keys = array ( 'name' , 'glyphs' , 'css_prefix_text' ) ; $ items = array ( ) ; foreach ( $ keys as $ key ) { if ( empty ( $ config [ $ key ] ) ) { trigger_error ( sprintf ( esc_html ( $ this -> messages [ 'invalid' ] ) , sprintf ( '<code><em>%s</em></code>' , esc_html ( $ key ) ) , esc_html ( $ config_file ) ) ) ; return false ; } } if ( ! is_array ( $ config [ 'glyphs' ] ) || empty ( $ config [ 'glyphs' ] ) ) { return false ; } foreach ( $ config [ 'glyphs' ] as $ glyph ) { if ( ! empty ( $ glyph [ 'css' ] ) ) { $ items [ ] = array ( 'id' => $ config [ 'css_prefix_text' ] . $ glyph [ 'css' ] , 'name' => $ glyph [ 'css' ] , ) ; } } if ( empty ( $ items ) ) { return false ; } $ pack_data = array ( 'id' => "pack-{$config['name']}" , 'name' => sprintf ( __ ( 'Pack: %s' , 'icon-picker' ) , $ config [ 'name' ] ) , 'version' => $ pack_dir -> getMTime ( ) , 'items' => $ items , 'stylesheet_uri' => "{$this->url}/{$pack_dirname}/css/{$config['name']}.css" , 'dir' => "{$this->dir}/{$pack_dirname}" , 'url' => "{$this->url}/{$pack_dirname}" , ) ; set_transient ( $ cache_id , $ pack_data , DAY_IN_SECONDS ) ; return $ pack_data ; }
Get icon pack data
53,875
protected function sendRequest ( $ method , $ url , $ body ) { $ options = [ 'headers' => [ 'Accept-Encoding' => 'gzip' , 'Content-Type' => 'application/json' , ] , 'body' => $ body , ] ; try { $ response = $ this -> client -> request ( $ method , $ url , $ options ) ; return json_decode ( $ response -> getBody ( ) , true ) ; } catch ( ClientException $ e ) { throw new PredictionIOAPIError ( $ e -> getMessage ( ) ) ; } }
Send a HTTP request to the server
53,876
public function setUser ( $ uid , array $ properties = array ( ) , $ eventTime = null ) { $ eventTime = $ this -> getEventTime ( $ eventTime ) ; if ( empty ( $ properties ) ) { $ properties = ( object ) $ properties ; } $ json = json_encode ( [ 'event' => '$set' , 'entityType' => 'user' , 'entityId' => $ uid , 'properties' => $ properties , 'eventTime' => $ eventTime , ] ) ; return $ this -> sendRequest ( 'POST' , $ this -> eventUrl , $ json ) ; }
Set a user entity
53,877
public function unsetUser ( $ uid , array $ properties , $ eventTime = null ) { $ eventTime = $ this -> getEventTime ( $ eventTime ) ; if ( empty ( $ properties ) ) { throw new PredictionIOAPIError ( 'Specify at least one property' ) ; } $ json = json_encode ( [ 'event' => '$unset' , 'entityType' => 'user' , 'entityId' => $ uid , 'properties' => $ properties , 'eventTime' => $ eventTime , ] ) ; return $ this -> sendRequest ( 'POST' , $ this -> eventUrl , $ json ) ; }
Unset a user entity
53,878
public function deleteUser ( $ uid , $ eventTime = null ) { $ eventTime = $ this -> getEventTime ( $ eventTime ) ; $ json = json_encode ( [ 'event' => '$delete' , 'entityType' => 'user' , 'entityId' => $ uid , 'eventTime' => $ eventTime , ] ) ; return $ this -> sendRequest ( 'POST' , $ this -> eventUrl , $ json ) ; }
Delete a user entity
53,879
public function setItem ( $ iid , array $ properties = array ( ) , $ eventTime = null ) { $ eventTime = $ this -> getEventTime ( $ eventTime ) ; if ( empty ( $ properties ) ) { $ properties = ( object ) $ properties ; } $ json = json_encode ( [ 'event' => '$set' , 'entityType' => 'item' , 'entityId' => $ iid , 'properties' => $ properties , 'eventTime' => $ eventTime , ] ) ; return $ this -> sendRequest ( 'POST' , $ this -> eventUrl , $ json ) ; }
Set an item entity
53,880
public function unsetItem ( $ iid , array $ properties , $ eventTime = null ) { $ eventTime = $ this -> getEventTime ( $ eventTime ) ; if ( empty ( $ properties ) ) { throw new PredictionIOAPIError ( 'Specify at least one property' ) ; } $ json = json_encode ( [ 'event' => '$unset' , 'entityType' => 'item' , 'entityId' => $ iid , 'properties' => $ properties , 'eventTime' => $ eventTime , ] ) ; return $ this -> sendRequest ( 'POST' , $ this -> eventUrl , $ json ) ; }
Unset an item entity
53,881
public function deleteItem ( $ iid , $ eventTime = null ) { $ eventTime = $ this -> getEventTime ( $ eventTime ) ; $ json = json_encode ( [ 'event' => '$delete' , 'entityType' => 'item' , 'entityId' => $ iid , 'eventTime' => $ eventTime , ] ) ; return $ this -> sendRequest ( 'POST' , $ this -> eventUrl , $ json ) ; }
Delete an item entity
53,882
public function recordUserActionOnItem ( $ event , $ uid , $ iid , array $ properties = array ( ) , $ eventTime = null ) { $ eventTime = $ this -> getEventTime ( $ eventTime ) ; if ( empty ( $ properties ) ) { $ properties = ( object ) $ properties ; } $ json = json_encode ( [ 'event' => $ event , 'entityType' => 'user' , 'entityId' => $ uid , 'targetEntityType' => 'item' , 'targetEntityId' => $ iid , 'properties' => $ properties , 'eventTime' => $ eventTime , ] ) ; return $ this -> sendRequest ( 'POST' , $ this -> eventUrl , $ json ) ; }
Record a user action on an item
53,883
private function buildBaseCriteria ( array $ parameters ) { $ criteriaGrouped = [ [ ] ] ; foreach ( $ parameters as $ name => $ value ) { switch ( $ name ) { case 'content_type' : case 'depth' : case 'main' : case 'parent_location_id' : case 'priority' : case 'publication_date' : case 'section' : case 'subtree' : case 'visible' : $ definitions = $ this -> getCriterionDefinitionResolver ( ) -> resolve ( $ name , $ value ) ; break ; case 'field' : case 'state' : $ definitions = $ this -> getCriterionDefinitionResolver ( ) -> resolveTargets ( $ name , $ value ) ; break ; default : continue 2 ; } $ criteriaGrouped [ ] = $ this -> getCriteriaBuilder ( ) -> build ( $ definitions ) ; } return array_merge ( ... $ criteriaGrouped ) ; }
Build criteria for the base supported options .
53,884
private function getPager ( Query $ query , QueryDefinition $ queryDefinition ) { if ( $ queryDefinition -> useFilter ) { $ adapter = new FilterAdapter ( $ query , $ this -> filterService ) ; } else { $ adapter = new FindAdapter ( $ query , $ this -> findService ) ; } $ pager = new Pagerfanta ( $ adapter ) ; $ pager -> setNormalizeOutOfRangePages ( true ) ; $ pager -> setMaxPerPage ( $ queryDefinition -> maxPerPage ) ; $ pager -> setCurrentPage ( $ queryDefinition -> page ) ; return $ pager ; }
Return Pagerfanta instance by the given parameters .
53,885
protected function createContentSearchPager ( Query $ query , $ currentPage , $ maxPerPage ) { @ trigger_error ( 'PagerfantaFindTrait is deprecated since version 2.5 and will be removed in 3.0. Use PagerfantaTrait instead.' , E_USER_DEPRECATED ) ; $ adapter = new ContentSearchAdapter ( $ query , $ this -> getSite ( ) -> getFindService ( ) ) ; return $ this -> getPager ( $ adapter , $ currentPage , $ maxPerPage ) ; }
Returns Pagerfanta pager that starts from first page configured with ContentSearchAdapter and FindService
53,886
protected function createContentSearchHitPager ( Query $ query , $ currentPage , $ maxPerPage ) { @ trigger_error ( 'PagerfantaFindTrait is deprecated since version 2.5 and will be removed in 3.0. Use PagerfantaTrait instead.' , E_USER_DEPRECATED ) ; $ adapter = new ContentSearchHitAdapter ( $ query , $ this -> getSite ( ) -> getFindService ( ) ) ; return $ this -> getPager ( $ adapter , $ currentPage , $ maxPerPage ) ; }
Returns Pagerfanta pager that starts from first page configured with ContentSearchHitAdapter and FindService
53,887
protected function createLocationSearchPager ( LocationQuery $ locationQuery , $ currentPage , $ maxPerPage ) { @ trigger_error ( 'PagerfantaFindTrait is deprecated since version 2.5 and will be removed in 3.0. Use PagerfantaTrait instead.' , E_USER_DEPRECATED ) ; $ adapter = new LocationSearchAdapter ( $ locationQuery , $ this -> getSite ( ) -> getFindService ( ) ) ; return $ this -> getPager ( $ adapter , $ currentPage , $ maxPerPage ) ; }
Returns Pagerfanta pager that starts from first page configured with LocationSearchAdapter and FindService
53,888
protected function createLocationSearchHitPager ( LocationQuery $ locationQuery , $ currentPage , $ maxPerPage ) { @ trigger_error ( 'PagerfantaFindTrait is deprecated since version 2.5 and will be removed in 3.0. Use PagerfantaTrait instead.' , E_USER_DEPRECATED ) ; $ adapter = new LocationSearchHitAdapter ( $ locationQuery , $ this -> getSite ( ) -> getFindService ( ) ) ; return $ this -> getPager ( $ adapter , $ currentPage , $ maxPerPage ) ; }
Returns Pagerfanta pager that starts from first page configured with LocationSearchHitAdapter and FindService
53,889
protected function getPager ( AdapterInterface $ adapter , $ currentPage , $ maxPerPage ) { @ trigger_error ( 'PagerfantaFindTrait is deprecated since version 2.5 and will be removed in 3.0. Use PagerfantaTrait instead.' , E_USER_DEPRECATED ) ; $ pager = new Pagerfanta ( $ adapter ) ; $ pager -> setNormalizeOutOfRangePages ( true ) ; $ pager -> setMaxPerPage ( $ maxPerPage ) ; $ pager -> setCurrentPage ( $ currentPage ) ; return $ pager ; }
Shorthand method for creating Pagerfanta pager with preconfigured Adapter
53,890
public function get_stylesheet_uri ( ) { $ stylesheet_uri = sprintf ( '%1$s/css/types/%2$s%3$s.css' , Icon_Picker :: instance ( ) -> url , $ this -> stylesheet_id , ( defined ( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min' ) ; $ stylesheet_uri = apply_filters ( 'icon_picker_icon_type_stylesheet_uri' , $ stylesheet_uri , $ this -> id , $ this ) ; return $ stylesheet_uri ; }
Get stylesheet URI
53,891
private function buildFieldSortClause ( array $ values , $ direction ) { if ( ! array_key_exists ( 1 , $ values ) ) { throw new InvalidArgumentException ( 'Field sort clause requires ContentType identifier' ) ; } if ( ! array_key_exists ( 2 , $ values ) ) { throw new InvalidArgumentException ( 'Field sort clause requires FieldDefinition identifier' ) ; } return new Field ( $ values [ 1 ] , $ values [ 2 ] , $ direction ) ; }
Build a new Field sort clause from the given arguments .
53,892
private function getLanguage ( array $ languageCodes , $ mainLanguageCode , $ alwaysAvailable ) { $ languageCodesSet = array_flip ( $ languageCodes ) ; foreach ( $ this -> settings -> prioritizedLanguages as $ languageCode ) { if ( isset ( $ languageCodesSet [ $ languageCode ] ) ) { return $ languageCode ; } } if ( $ this -> settings -> useAlwaysAvailable && $ alwaysAvailable ) { return $ mainLanguageCode ; } return null ; }
Returns the most prioritized language for the given parameters .
53,893
private function getContext ( VersionInfo $ versionInfo ) { return [ 'prioritizedLanguages' => $ this -> settings -> prioritizedLanguages , 'useAlwaysAvailable' => $ this -> settings -> useAlwaysAvailable , 'availableTranslations' => $ versionInfo -> languageCodes , 'mainTranslation' => $ versionInfo -> contentInfo -> mainLanguageCode , 'alwaysAvailable' => $ versionInfo -> contentInfo -> alwaysAvailable , ] ; }
Returns an array describing language resolving context .
53,894
public function createEvent ( $ event , $ entityType , $ entityId , $ targetEntityType = null , $ targetEntityId = null , array $ properties = null , $ eventTime = null ) { if ( ! isset ( $ eventTime ) ) { $ eventTime = new \ DateTime ( ) ; } elseif ( ! ( $ eventTime instanceof \ DateTime ) ) { $ eventTime = new \ DateTime ( $ eventTime ) ; } $ eventTime = $ eventTime -> format ( \ DateTime :: ISO8601 ) ; $ data = [ 'event' => $ event , 'entityType' => $ entityType , 'entityId' => $ entityId , 'eventTime' => $ eventTime , ] ; if ( isset ( $ targetEntityType ) ) { $ data [ 'targetEntityType' ] = $ targetEntityType ; } if ( isset ( $ targetEntityId ) ) { $ data [ 'targetEntityId' ] = $ targetEntityId ; } if ( isset ( $ properties ) ) { $ data [ 'properties' ] = $ properties ; } $ json = $ this -> jsonEncode ( $ data ) ; $ this -> export ( $ json ) ; }
Create and export a json - encoded event .
53,895
protected function createCookieDriver ( ) { $ determiner = new Determiners \ Cookie ( $ this -> app [ 'config' ] [ 'localize-middleware' ] [ 'cookie' ] ) ; $ determiner -> setFallback ( $ this -> app [ 'config' ] [ 'app' ] [ 'fallback_locale' ] ) ; return $ determiner ; }
Get a cookie determiner instance .
53,896
protected function createHostDriver ( ) { $ determiner = new Determiners \ Host ( new Collection ( $ this -> app [ 'config' ] [ 'localize-middleware' ] [ 'hosts' ] ) ) ; $ determiner -> setFallback ( $ this -> app [ 'config' ] [ 'app' ] [ 'fallback_locale' ] ) ; return $ determiner ; }
Get a host determiner instance .
53,897
protected function createParameterDriver ( ) { $ determiner = new Determiners \ Parameter ( $ this -> app [ 'config' ] [ 'localize-middleware' ] [ 'parameter' ] ) ; $ determiner -> setFallback ( $ this -> app [ 'config' ] [ 'app' ] [ 'fallback_locale' ] ) ; return $ determiner ; }
Get a parameter determiner instance .
53,898
protected function createHeaderDriver ( ) { $ determiner = new Determiners \ Header ( $ this -> app [ 'config' ] [ 'localize-middleware' ] [ 'header' ] ) ; $ determiner -> setFallback ( $ this -> app [ 'config' ] [ 'app' ] [ 'fallback_locale' ] ) ; return $ determiner ; }
Get a header determiner instance .
53,899
protected function createSessionDriver ( ) { $ determiner = new Determiners \ Session ( $ this -> app [ 'config' ] [ 'localize-middleware' ] [ 'session' ] ) ; $ determiner -> setFallback ( $ this -> app [ 'config' ] [ 'app' ] [ 'fallback_locale' ] ) ; return $ determiner ; }
Get a session determiner instance .