idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
23,800 | private function getSupportedAttribute ( $ event ) { $ model = $ event -> getModel ( ) ; if ( ! $ model instanceof Model ) { return null ; } $ property = $ event -> getProperty ( ) ; $ attribute = $ model -> getItem ( ) -> getAttribute ( $ property ) ; if ( $ attribute instanceof Timestamp ) { return $ attribute ; } return null ; } | Get the supported attribute or null . |
23,801 | protected function hydrateItem ( $ objectClass , array $ item ) { $ object = $ this -> createObjectToHydrate ( $ objectClass ) ; if ( 0 == count ( $ item ) ) { return $ object ; } $ hydrator = $ this -> objectManager -> getHydratorFor ( $ objectClass ) ; return $ hydrator -> hydrate ( $ item , $ object ) ; } | Create an hydrate an entity from a raw results . |
23,802 | public function add ( $ location ) : bool { if ( $ this -> hasLocation ( $ location ) ) { return false ; } return parent :: add ( $ location ) ; } | Adds a location at the end of the collection if it does not already exist . |
23,803 | public function hasLocation ( Location $ location ) : bool { return $ this -> exists ( function ( $ key , $ element ) use ( $ location ) { return $ location == $ element ; } ) ; } | Check whether a given location is already registered . |
23,804 | public function AsHTML ( $ useGFM = false ) { if ( $ this -> parsedHTML !== false ) { return $ this -> parsedHTML ; } $ renderer = $ this -> getRenderer ( ) ; $ supported = $ renderer -> isSupported ( ) ; if ( $ supported !== true ) { $ class_name = get_class ( $ renderer ) ; user_error ( "Renderer $class_name is not supported on this system: $supported" ) ; } if ( $ renderer instanceof GithubMarkdownRenderer ) { $ beforeUseGFM = GithubMarkdownRenderer :: getUseGFM ( ) ; GithubMarkdownRenderer :: setUseGFM ( $ useGFM ) ; } $ cacheKey = md5 ( 'Markdown_' . $ this -> tableName . '_' . $ this -> name . ':' . $ this -> value ) ; $ cache = SS_Cache :: factory ( 'Markdown' ) ; $ cachedHTML = $ cache -> load ( $ cacheKey ) ; if ( $ cachedHTML !== false ) { $ this -> parsedHTML = $ cachedHTML ; return $ this -> parsedHTML ; } if ( empty ( $ this -> value ) ) { return $ this -> value ; } $ response = $ renderer -> getRenderedHTML ( $ this -> value ) ; $ this -> parsedHTML = $ response ; $ cache -> save ( $ this -> parsedHTML , $ cacheKey ) ; if ( $ renderer instanceof GithubMarkdownRenderer ) { GithubMarkdownRenderer :: setUseGFM ( $ beforeUseGFM ) ; } return $ this -> parsedHTML ; } | Checks cache to see if the contents of this field have already been loaded from github if they haven t then a request is made to the github api to render the markdown |
23,805 | public static function setRenderer ( $ renderer ) { if ( ClassInfo :: classImplements ( $ renderer , 'IMarkdownRenderer' ) ) { self :: $ renderer = $ renderer ; } else { user_error ( 'The renderer ' . $ renderer . ' does not implement IMarkdownRenderer' , E_USER_ERROR ) ; } } | Sets the renderer for markdown fields to use |
23,806 | private function getRenderer ( ) { if ( ! is_object ( $ this -> renderInst ) ) { $ class = self :: $ renderer ; $ this -> renderInst = new $ class ( ) ; } return $ this -> renderInst ; } | Gets the active mardown renderer |
23,807 | public function getDescriptor ( string $ classNamespace ) : ? Descriptor { if ( ! $ this -> isEmpty ( ) ) { foreach ( $ this as $ rootNamespace => $ descriptor ) { $ rootNamespace = $ descriptor -> getRootNamespace ( ) ; $ doubleSlashed = str_replace ( '\\' , '\\\\' , $ rootNamespace ) ; $ pattern = sprintf ( '|^%s\\.*|' , $ doubleSlashed ) ; if ( preg_match ( $ pattern , $ classNamespace ) ) { return $ descriptor ; } } } return null ; } | Returns descriptor of bundle that contains given class |
23,808 | public function getDescriptorByName ( string $ bundleName ) : ? Descriptor { if ( ! $ this -> isEmpty ( ) ) { foreach ( $ this as $ rootNamespace => $ descriptor ) { $ name = $ descriptor -> getName ( ) ; if ( $ bundleName === $ name ) { return $ descriptor ; } } } return null ; } | Returns descriptor of bundle with given name |
23,809 | public static function fromArray ( array $ data ) : Descriptors { $ descriptors = new static ( ) ; if ( ! empty ( $ data ) ) { foreach ( $ data as $ descriptorData ) { $ descriptor = Descriptor :: fromArray ( $ descriptorData ) ; $ rootNamespace = $ descriptor -> getRootNamespace ( ) ; $ descriptors -> add ( $ descriptor , $ rootNamespace ) ; } } return $ descriptors ; } | Returns the descriptors created from given data |
23,810 | public function FieldHolder ( $ properties = array ( ) ) { $ this -> extraClasses [ 'stacked' ] = 'stacked' ; Requirements :: css ( MARKDOWN_MODULE_BASE . '/css/MarkdownEditor.css' ) ; Requirements :: javascript ( MARKDOWN_MODULE_BASE . '/javascript/external/ace/ace.js' ) ; Requirements :: javascript ( MARKDOWN_MODULE_BASE . '/javascript/external/ace/mode-markdown.js' ) ; Requirements :: javascript ( MARKDOWN_MODULE_BASE . '/javascript/external/ace/theme-textmate.js' ) ; Requirements :: javascript ( MARKDOWN_MODULE_BASE . '/javascript/external/ace/theme-twilight.js' ) ; Requirements :: javascript ( MARKDOWN_MODULE_BASE . '/javascript/MarkdownEditor.js' ) ; return parent :: FieldHolder ( $ properties ) ; } | Returns the field holder used by templates |
23,811 | protected function getDefaultInputDefinition ( ) { return new InputDefinition ( array ( new InputOption ( '--help' , '-h' , InputOption :: VALUE_NONE , 'Display this help message.' ) , new InputOption ( '--quiet' , '-q' , InputOption :: VALUE_NONE , 'Do not output any message.' ) , new InputOption ( '--verbose' , '-v' , InputOption :: VALUE_NONE , 'Increase verbosity of messages.' ) , new InputOption ( '--version' , '-V' , InputOption :: VALUE_NONE , 'Display this application version.' ) , new InputOption ( '--ansi' , '' , InputOption :: VALUE_NONE , 'Force ANSI output.' ) , new InputOption ( '--no-ansi' , '' , InputOption :: VALUE_NONE , 'Disable ANSI output.' ) , new InputOption ( '--no-interaction' , '-n' , InputOption :: VALUE_NONE , 'Do not ask any interactive question.' ) , new InputOption ( '--config' , '-c' , InputOption :: VALUE_REQUIRED , 'Path to a configuration file' ) , new InputOption ( '--profile' , '-p' , InputOption :: VALUE_REQUIRED , 'Chosen configuration profile' ) , new InputOption ( '--bootstrap' , '-b' , InputOption :: VALUE_REQUIRED , 'A php bootstrap file' ) , ) ) ; } | Gets the default input definition . |
23,812 | public function getFeatureType ( ConnectionInterface $ con = null ) { if ( $ this -> aFeatureType === null && ( $ this -> id !== null ) ) { $ this -> aFeatureType = ChildFeatureTypeQuery :: create ( ) -> findPk ( $ this -> id , $ con ) ; } return $ this -> aFeatureType ; } | Get the associated ChildFeatureType object |
23,813 | public static function replaceBinaryStrings ( $ message ) { $ lines = explode ( "\r\n" , $ message ) ; foreach ( $ lines as & $ line ) { if ( ! mb_check_encoding ( $ line , 'utf-8' ) ) { $ line = '<' . strlen ( $ line ) . ' bytes binary content>' ; } } return implode ( "\r\n" , $ lines ) ; } | Replaces the lines containing binary strings with a human readable replacement . |
23,814 | public function getTokenForUser ( User $ user , int $ validForSeconds = null , array $ additionalData = [ ] ) : string { $ tokenData = [ 'user_id' => $ user -> id , 'generated' => time ( ) , 'validForSeconds' => $ validForSeconds , 'additionalData' => $ additionalData , ] ; $ tokenDataString = serialize ( $ tokenData ) ; $ encrypted = Security :: encrypt ( $ tokenDataString , Configure :: read ( 'Security.cryptKey' ) ) ; return base64_encode ( $ encrypted ) ; } | Generates a serialized encrypted and base64 - encoded for identifying a user usually for using it in an URL |
23,815 | public function isTokenValid ( string $ token ) : bool { $ tokenData = $ this -> decryptToken ( $ token ) ; return is_array ( $ tokenData ) && isset ( $ tokenData [ 'user_id' ] , $ tokenData [ 'generated' ] , $ tokenData [ 'validForSeconds' ] ) ; } | Checks if the given token is valid meaning it is valid by format . This method does not check the validity |
23,816 | public function isTokenExpired ( string $ token ) : bool { if ( ! $ this -> isTokenValid ( $ token ) ) { throw new \ InvalidArgumentException ( 'This token is invalid' ) ; } $ tokenData = $ this -> decryptToken ( $ token ) ; $ tokenExpiration = $ tokenData [ 'generated' ] + $ tokenData [ 'validForSeconds' ] ; return $ tokenExpiration < time ( ) ; } | Checks if the given token is expired |
23,817 | public function getUserIdFromToken ( string $ token ) : string { if ( ! $ this -> isTokenValid ( $ token ) ) { throw new \ InvalidArgumentException ( 'This token is invalid' ) ; } $ tokenData = $ this -> decryptToken ( $ token ) ; return $ tokenData [ 'user_id' ] ; } | Returns the user id from the given token |
23,818 | public function decryptToken ( string $ token ) { $ tokenData = false ; $ encrypted = base64_decode ( $ token ) ; if ( $ encrypted ) { $ serialized = Security :: decrypt ( $ encrypted , Configure :: read ( 'Security.cryptKey' ) ) ; $ tokenData = unserialize ( $ serialized ) ; } return $ tokenData ; } | Tries to decode decrypt and unserialize the given token and return the data as an array |
23,819 | protected function getUrlFromConfiguration ( $ routeName , $ configuration , $ item = null ) { foreach ( $ configuration [ 'route_parameters' ] as $ key => $ parameter ) { $ configuration [ 'route_parameters' ] [ $ key ] = $ this -> getItemParameter ( $ item , $ parameter ) ; } $ url = $ this -> router -> generate ( $ routeName , $ configuration [ 'route_parameters' ] ) ; $ urlObject = new Url ( $ url , ( isset ( $ configuration [ 'last_mod' ] ) ? $ this -> getItemParameter ( $ item , $ configuration [ 'last_mod' ] ) : null ) , ( isset ( $ configuration [ 'priority' ] ) ? $ this -> getItemParameter ( $ item , $ configuration [ 'priority' ] ) : null ) , ( isset ( $ configuration [ 'change_freq' ] ) ? $ this -> getItemParameter ( $ item , $ configuration [ 'change_freq' ] ) : null ) ) ; return $ urlObject ; } | Create URL object from route configuration |
23,820 | public function storeRefererUrl ( string $ url ) : RequestService { $ this -> session -> set ( $ this -> refererUrlKey , $ url ) ; return $ this ; } | Stores url of referer in session |
23,821 | public function storeRefererUrlFromRequest ( Request $ request ) : RequestService { $ url = $ this -> getRefererUrl ( $ request ) ; if ( '' === $ url ) { return $ this ; } return $ this -> storeRefererUrl ( $ url ) ; } | Stores the referer url in session grabbed from given request |
23,822 | public function fetchRefererUrl ( ) : string { $ url = $ this -> session -> get ( $ this -> refererUrlKey , '' ) ; $ this -> session -> remove ( $ this -> refererUrlKey ) ; return $ url ; } | Fetches url of referer and removes it from session |
23,823 | public static function isAttachment ( WP_Post $ post , string $ message = null ) : void { $ postType = $ post -> post_type ; 'attachment' === $ postType or static :: reportInvalidArgument ( $ message ? : "Expected Post be an Attachment. Type of {$postType} Given." ) ; } | Assert a WP_Post Entity is an Attachment |
23,824 | private function getFileLoader ( ContainerBuilder $ container , FileLocator $ locator , string $ fileType ) : ? FileLoader { $ loader = null ; switch ( $ fileType ) { case ConfigurationFileType :: YAML : $ loader = new YamlFileLoader ( $ container , $ locator ) ; break ; case ConfigurationFileType :: XML : $ loader = new XmlFileLoader ( $ container , $ locator ) ; break ; case ConfigurationFileType :: PHP : $ loader = new PhpFileLoader ( $ container , $ locator ) ; break ; } return $ loader ; } | Returns loader of the configuration file |
23,825 | private function loadParameters ( array $ mergedConfig , ContainerBuilder $ container ) : BaseExtension { if ( empty ( $ mergedConfig ) ) { return $ this ; } $ keysToStop = $ this -> getKeysToStopLoadingParametersOn ( ) ; $ globalKeysToStop = $ this -> getGlobalKeysToStopLoadingParametersOn ( ) ; $ keysToStop = Arrays :: makeArray ( $ keysToStop ) ; $ globalKeysToStop = Arrays :: makeArray ( $ globalKeysToStop ) ; $ stopIfMatchedBy = array_merge ( $ keysToStop , $ globalKeysToStop ) ; $ parameters = Arrays :: getLastElementsPaths ( $ mergedConfig , '.' , '' , $ stopIfMatchedBy ) ; $ configuration = $ this -> getConfiguration ( $ mergedConfig , $ container ) ; $ bundleShortName = $ configuration -> getConfigTreeBuilder ( ) -> buildTree ( ) -> getName ( ) ; foreach ( $ parameters as $ name => $ value ) { if ( ! \ is_array ( $ value ) ) { $ value = Miscellaneous :: trimSmart ( $ value ) ; } $ prefixedName = sprintf ( '%s.%s' , $ bundleShortName , $ name ) ; $ container -> setParameter ( $ prefixedName , $ value ) ; } return $ this ; } | Loads parameters into container |
23,826 | public function create ( ) { try { $ this -> dispatch ( new AttemptRememberingUser ( ) ) ; return redirect ( ) -> intended ( $ this -> config -> get ( 'authentication.login.redirectUri' ) ) ; } catch ( RememberingUserFailed $ e ) { return view ( 'authentication::session.create' ) ; } } | Attempts to authenticate by remember token . When remembering fails the login form is shown . |
23,827 | public function store ( Request $ request ) { try { $ this -> dispatch ( new AttemptUserLogin ( $ request -> get ( 'email' ) , $ request -> get ( 'password' ) , $ request -> get ( 'remember' ) ) ) ; return redirect ( ) -> intended ( $ this -> config -> get ( 'authentication.login.redirectUri' ) ) ; } catch ( LoginFailed $ e ) { return redirect ( ) -> back ( ) -> withInput ( ) -> withErrors ( [ 'authentication::login_error' => $ e -> getMessage ( ) ] ) ; } catch ( UserIsBanned $ e ) { return redirect ( ) -> back ( ) -> withInput ( ) -> withErrors ( [ 'authentication::login_error' => $ e -> getMessage ( ) ] ) ; } } | Attempts to login the user . |
23,828 | public function destroy ( ) { try { $ this -> dispatch ( new PerformUserLogout ( ) ) ; return redirect ( $ this -> config -> get ( 'authentication.logout.redirectUri' ) ) ; } catch ( SessionHasExpired $ e ) { return redirect ( ) -> route ( 'authentication::session.create' ) -> withErrors ( [ 'authentication::login_warning' => $ e -> getMessage ( ) ] ) ; } } | Attempts to log off the user . |
23,829 | private function loadSource ( Model \ Source $ sourceModel , array $ sourceData ) { $ sourceModel -> setId ( $ sourceData [ 'id' ] ) -> setMethod ( new Model \ Method ( $ sourceData [ 'class' ] , $ sourceData [ 'method' ] , $ sourceData [ 'args' ] ) ) -> setLazyLoading ( $ sourceData [ 'lazyLoading' ] ) -> setSupplySeveralFields ( $ sourceData [ 'supplySeveralFields' ] ) -> setOnFail ( $ sourceData [ 'onFail' ] ) -> setExceptionClass ( $ sourceData [ 'exceptionClass' ] ) -> setBadReturnValue ( $ sourceData [ 'badReturnValue' ] ) -> setFallbackSourceId ( $ sourceData [ 'fallbackSourceId' ] ) -> setDepends ( $ sourceData [ 'depends' ] ) ; if ( isset ( $ sourceData [ 'preprocessor' ] [ 'method' ] ) ) { $ sourceModel -> addPreprocessor ( new Model \ Method ( $ sourceData [ 'preprocessor' ] [ 'class' ] , $ sourceData [ 'preprocessor' ] [ 'method' ] , $ sourceData [ 'preprocessor' ] [ 'args' ] ) ) ; } elseif ( isset ( $ sourceData [ 'preprocessors' ] ) ) { foreach ( $ sourceData [ 'preprocessors' ] as $ preprocessor ) { $ sourceModel -> addPreprocessor ( new Model \ Method ( $ preprocessor [ 'class' ] , $ preprocessor [ 'method' ] , $ preprocessor [ 'args' ] ) ) ; } } if ( isset ( $ sourceData [ 'processor' ] [ 'method' ] ) ) { $ sourceModel -> addProcessor ( new Model \ Method ( $ sourceData [ 'processor' ] [ 'class' ] , $ sourceData [ 'processor' ] [ 'method' ] , $ sourceData [ 'processor' ] [ 'args' ] ) ) ; } elseif ( isset ( $ sourceData [ 'processors' ] ) ) { foreach ( $ sourceData [ 'processors' ] as $ processor ) { $ sourceModel -> addProcessor ( new Model \ Method ( $ processor [ 'class' ] , $ processor [ 'method' ] , $ processor [ 'args' ] ) ) ; } } return $ sourceModel ; } | Hydrate a source model from raw datas . |
23,830 | public function filterByFeatureAvId ( $ featureAvId = null , $ comparison = null ) { if ( is_array ( $ featureAvId ) ) { $ useMinMax = false ; if ( isset ( $ featureAvId [ 'min' ] ) ) { $ this -> addUsingAlias ( FeatureTypeAvMetaTableMap :: FEATURE_AV_ID , $ featureAvId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ featureAvId [ 'max' ] ) ) { $ this -> addUsingAlias ( FeatureTypeAvMetaTableMap :: FEATURE_AV_ID , $ featureAvId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( FeatureTypeAvMetaTableMap :: FEATURE_AV_ID , $ featureAvId , $ comparison ) ; } | Filter the query on the feature_av_id column |
23,831 | public function filterByFeatureFeatureTypeId ( $ featureFeatureTypeId = null , $ comparison = null ) { if ( is_array ( $ featureFeatureTypeId ) ) { $ useMinMax = false ; if ( isset ( $ featureFeatureTypeId [ 'min' ] ) ) { $ this -> addUsingAlias ( FeatureTypeAvMetaTableMap :: FEATURE_FEATURE_TYPE_ID , $ featureFeatureTypeId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ featureFeatureTypeId [ 'max' ] ) ) { $ this -> addUsingAlias ( FeatureTypeAvMetaTableMap :: FEATURE_FEATURE_TYPE_ID , $ featureFeatureTypeId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( FeatureTypeAvMetaTableMap :: FEATURE_FEATURE_TYPE_ID , $ featureFeatureTypeId , $ comparison ) ; } | Filter the query on the feature_feature_type_id column |
23,832 | public function filterByLocale ( $ locale = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ locale ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ locale ) ) { $ locale = str_replace ( '*' , '%' , $ locale ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( FeatureTypeAvMetaTableMap :: LOCALE , $ locale , $ comparison ) ; } | Filter the query on the locale column |
23,833 | public function filterByFeatureAv ( $ featureAv , $ comparison = null ) { if ( $ featureAv instanceof \ Thelia \ Model \ FeatureAv ) { return $ this -> addUsingAlias ( FeatureTypeAvMetaTableMap :: FEATURE_AV_ID , $ featureAv -> getId ( ) , $ comparison ) ; } elseif ( $ featureAv instanceof ObjectCollection ) { if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } return $ this -> addUsingAlias ( FeatureTypeAvMetaTableMap :: FEATURE_AV_ID , $ featureAv -> toKeyValue ( 'PrimaryKey' , 'Id' ) , $ comparison ) ; } else { throw new PropelException ( 'filterByFeatureAv() only accepts arguments of type \Thelia\Model\FeatureAv or Collection' ) ; } } | Filter the query by a related \ Thelia \ Model \ FeatureAv object |
23,834 | public function useFeatureAvQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinFeatureAv ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'FeatureAv' , '\Thelia\Model\FeatureAvQuery' ) ; } | Use the FeatureAv relation FeatureAv object |
23,835 | public function useFeatureFeatureTypeQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinFeatureFeatureType ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'FeatureFeatureType' , '\FeatureType\Model\FeatureFeatureTypeQuery' ) ; } | Use the FeatureFeatureType relation FeatureFeatureType object |
23,836 | private function createCountry ( DOMElement $ element ) { if ( $ element -> hasAttribute ( 'common_name' ) ) { $ short = $ element -> getAttribute ( 'common_name' ) ; } else { $ short = $ element -> getAttribute ( 'name' ) ; } if ( $ element -> hasAttribute ( 'official_name' ) ) { $ long = $ element -> getAttribute ( 'official_name' ) ; } else { $ long = null ; } return new Country ( $ element -> getAttribute ( 'alpha_2_code' ) , $ element -> getAttribute ( 'alpha_3_code' ) , $ long , $ element -> getAttribute ( 'numeric_code' ) , $ short ) ; } | Creates a new Country using an XML element . |
23,837 | private function getCountry ( ) { if ( null === $ this -> country ) { $ this -> country = $ this -> loadXml ( $ this -> countryFile ) ; } return $ this -> country ; } | Returns the country XPath object . |
23,838 | private function getSubdivision ( ) { if ( null === $ this -> subdivision ) { $ this -> subdivision = $ this -> loadXml ( $ this -> subdivisionFile ) ; } return $ this -> subdivision ; } | Returns the subdivision XPath object . |
23,839 | private function loadXml ( $ file ) { $ internal = libxml_use_internal_errors ( true ) ; $ doc = new DOMDocument ( ) ; $ doc -> preserveWhiteSpace = false ; $ doc -> validateOnParse = true ; if ( ! @ $ doc -> load ( $ file ) ) { $ errors = libxml_get_errors ( ) ; libxml_use_internal_errors ( $ internal ) ; throw XmlException :: createUsingErrors ( $ errors ) ; } libxml_use_internal_errors ( $ internal ) ; return new DOMXPath ( $ doc ) ; } | Loads and validates an XML document from a file for querying . |
23,840 | public function update ( ChangePasswordRequest $ request , Guard $ auth ) { try { $ this -> dispatch ( new ChangePassword ( $ auth -> user ( ) -> id , $ request -> get ( 'current_password' ) , $ request -> get ( 'new_password' ) ) ) ; return redirect ( ) -> route ( 'authentication::profile.show' ) ; } catch ( ValidationException $ e ) { return redirect ( ) -> back ( ) -> withErrors ( $ e -> errors ( ) ) ; } } | Attempts to update the password . |
23,841 | private function getOrientation ( $ filename ) { $ exif = @ exif_read_data ( $ filename ) ; if ( $ exif === null ) return 0 ; $ rotation = 0 ; if ( ! empty ( $ exif [ 'Orientation' ] ) ) { switch ( $ exif [ 'Orientation' ] ) { case 3 : $ rotation = 180 ; break ; case 6 : $ rotation = 90 ; break ; case 8 : $ rotation = - 90 ; break ; } } return $ rotation ; } | Return the orientation of an image |
23,842 | protected function sortChannels ( ArrayCollection $ channels ) { $ channels -> map ( function ( $ channel ) { $ channel -> setChildren ( $ this -> sortChannels ( $ channel -> getChildren ( ) ) ) ; } ) ; $ iterator = $ channels -> getIterator ( ) ; $ iterator -> uasort ( function ( $ a , $ b ) { return $ a -> getName ( ) > $ b -> getName ( ) ; } ) ; return new ArrayCollection ( iterator_to_array ( $ iterator ) ) ; } | Since the VMPro API doesn t sort any more the returned channels we have to do it on our side . |
23,843 | private function getOptions ( array $ config = [ ] ) : array { $ resolver = new OptionsResolver ( ) ; $ resolver -> setDefaults ( [ 'timeout' => 5 , 'verify_peer' => true , 'verify_host' => 2 , 'proxy' => null , ] ) ; $ resolver -> setAllowedTypes ( 'timeout' , 'int' ) ; $ resolver -> setAllowedTypes ( 'verify_peer' , 'bool' ) ; $ resolver -> setAllowedTypes ( 'verify_host' , 'int' ) ; $ resolver -> setAllowedTypes ( 'proxy' , [ 'string' , 'null' ] ) ; return $ resolver -> resolve ( $ config ) ; } | Get options to configure the Buzz client . |
23,844 | public function validForUpdate ( $ user , array $ credentials ) { if ( $ user instanceof UserInterface ) { $ user = $ user -> getUserId ( ) ; } return $ this -> validate ( $ credentials , $ user ) ; } | Validate if the given user is valid for updating . |
23,845 | public function createHttpClient ( $ baseUri , array $ middlewares = [ ] , array $ options = [ ] ) { $ stack = HandlerStack :: create ( ) ; foreach ( $ middlewares as $ middleware ) { $ stack -> push ( $ middleware ) ; } return new Client ( array_merge ( [ 'base_uri' => $ baseUri , 'handler' => $ stack , ] , $ options ) ) ; } | Method to instantiate a HTTP client . |
23,846 | public function getMetadataExtensionClassByMappedField ( $ mappedFieldName ) { $ prefix = '' ; if ( null != $ data = $ this -> getDataForField ( $ mappedFieldName , $ this -> columnDataName ) ) { switch ( true ) { case isset ( $ data [ 'fieldMappingExtensionClass' ] ) : return $ prefix . $ data [ 'fieldMappingExtensionClass' ] ; case isset ( $ this -> propertyMetadataExtensionClass ) : return $ prefix . $ this -> propertyMetadataExtensionClass ; } } return null ; } | Gets the value of metadataExtensionClass for a given fieldName . |
23,847 | public function resize ( $ width , $ height ) { $ newImage = imagecreatetruecolor ( $ width , $ height ) ; $ this -> strategy -> handleTransparency ( $ newImage , $ this -> image ) ; imagecopyresampled ( $ newImage , $ this -> image , 0 , 0 , 0 , 0 , $ width , $ height , $ this -> getWidth ( ) , $ this -> getHeight ( ) ) ; $ this -> image = $ newImage ; } | Now with added Transparency resizing feature |
23,848 | public function create ( UserInterface $ user ) { $ entity = static :: ENTITY_CLASSNAME ; $ activation = new $ entity ( $ user ) ; $ this -> save ( $ activation ) ; return $ activation ; } | Create a new activation record and code . |
23,849 | public function pushToIndices ( SearchableInterface $ searchableModel ) { $ indices = $ this -> initIndices ( $ searchableModel ) ; $ record = $ searchableModel -> getAlgoliaRecord ( ) ; return $ this -> processIndices ( $ indices , function ( Index $ index ) use ( $ record , $ searchableModel ) { return $ index -> addObject ( $ record , $ searchableModel -> getObjectID ( ) ) ; } ) ; } | Indexes a searchable model to all indices . |
23,850 | public function pushMultipleToIndices ( array $ searchableModels ) { $ algoliaRecords = $ this -> getAlgoliaRecordsFromSearchableModelArray ( $ searchableModels ) ; $ indices = $ this -> initIndices ( $ searchableModels [ 0 ] ) ; return $ this -> processIndices ( $ indices , function ( Index $ index ) use ( $ algoliaRecords ) { return $ index -> addObjects ( $ algoliaRecords ) ; } ) ; } | Indexes multiple searchable models in a batch . The given searchable models must be of the same class . |
23,851 | public function updateInIndices ( SearchableInterface $ searchableModel ) { $ indices = $ this -> initIndices ( $ searchableModel ) ; $ record = $ searchableModel -> getAlgoliaRecord ( ) ; $ record [ 'objectID' ] = $ searchableModel -> getObjectID ( ) ; return $ this -> processIndices ( $ indices , function ( Index $ index ) use ( $ record ) { return $ index -> saveObject ( $ record ) ; } ) ; } | Updates the models data in all indices . |
23,852 | public function updateMultipleInIndices ( array $ searchableModels ) { $ algoliaRecords = $ this -> getAlgoliaRecordsFromSearchableModelArray ( $ searchableModels ) ; $ indices = $ this -> initIndices ( $ searchableModels [ 0 ] ) ; return $ this -> processIndices ( $ indices , function ( Index $ index ) use ( $ algoliaRecords ) { return $ index -> saveObjects ( $ algoliaRecords ) ; } ) ; } | Updates multiple models data in all indices . The given searchable models must be of the same class . |
23,853 | public function removeFromIndices ( SearchableInterface $ searchableModel ) { $ indices = $ indices = $ this -> initIndices ( $ searchableModel ) ; $ objectID = $ searchableModel -> getObjectID ( ) ; return $ this -> processIndices ( $ indices , function ( Index $ index ) use ( $ objectID ) { return $ index -> deleteObject ( $ objectID ) ; } ) ; } | Removes a searchable model from indices . |
23,854 | public function removeMultipleFromIndices ( array $ searchableModels ) { $ algoliaRecords = $ this -> getAlgoliaRecordsFromSearchableModelArray ( $ searchableModels ) ; $ indices = $ this -> initIndices ( $ searchableModels [ 0 ] ) ; $ objectIds = \ array_map ( function ( $ algoliaRecord ) { return $ algoliaRecord [ 'objectID' ] ; } , $ algoliaRecords ) ; return $ this -> processIndices ( $ indices , function ( Index $ index ) use ( $ objectIds ) { return $ index -> deleteObjects ( $ objectIds ) ; } ) ; } | Removes multiple models from all indices . The given searchable models must be of the same class . |
23,855 | public function reindex ( $ className ) { $ this -> checkImplementsSearchableInterface ( $ className ) ; $ activeRecord = $ this -> activeRecordFactory -> make ( $ className ) ; $ records = $ this -> activeQueryChunker -> chunk ( $ activeRecord -> find ( ) , self :: CHUNK_SIZE , function ( $ activeRecordEntities ) { return $ this -> getAlgoliaRecordsFromSearchableModelArray ( $ activeRecordEntities ) ; } ) ; $ indices = $ this -> initIndices ( $ activeRecord ) ; return $ this -> processIndices ( $ indices , function ( Index $ index ) use ( $ records ) { return $ this -> reindexAtomically ( $ index , $ records ) ; } ) ; } | Re - indexes the indices safely for the given ActiveRecord Class . |
23,856 | public function reindexOnly ( array $ searchableModels ) { $ records = $ this -> getAlgoliaRecordsFromSearchableModelArray ( $ searchableModels ) ; $ indices = $ this -> initIndices ( $ searchableModels [ 0 ] ) ; return $ this -> processIndices ( $ indices , function ( Index $ index ) use ( $ records ) { return $ this -> reindexAtomically ( $ index , $ records ) ; } ) ; } | Re - indexes the related indices for the given array only with the objects from the given array . The given array must consist of Searchable objects of same class . |
23,857 | public function reindexByActiveQuery ( ActiveQueryInterface $ activeQuery ) { $ indices = null ; $ records = $ this -> activeQueryChunker -> chunk ( $ activeQuery , self :: CHUNK_SIZE , function ( $ activeRecordEntities ) use ( & $ indices ) { $ records = $ this -> getAlgoliaRecordsFromSearchableModelArray ( $ activeRecordEntities ) ; if ( $ indices === null ) { $ indices = $ this -> initIndices ( $ activeRecordEntities [ 0 ] ) ; } return $ records ; } ) ; return $ this -> processIndices ( $ indices , function ( Index $ index ) use ( $ records ) { return $ this -> reindexAtomically ( $ index , $ records ) ; } ) ; } | Re - indexes the related indices for the given ActiveQueryInterface . The result of the given ActiveQuery must consist from Searchable models of the same class . |
23,858 | public function clearIndices ( $ className ) { $ this -> checkImplementsSearchableInterface ( $ className ) ; $ activeRecord = $ this -> activeRecordFactory -> make ( $ className ) ; $ indices = $ indices = $ this -> initIndices ( $ activeRecord ) ; return $ this -> processIndices ( $ indices , function ( Index $ index ) { return $ index -> clearIndex ( ) ; } ) ; } | Clears the indices for the given Class that implements SearchableInterface . |
23,859 | private function initIndices ( SearchableInterface $ searchableModel ) { $ indexNames = $ searchableModel -> getIndices ( ) ; return \ array_map ( function ( $ indexName ) { if ( $ this -> env !== null ) { $ indexName = $ this -> env . '_' . $ indexName ; } return $ this -> initIndex ( $ indexName ) ; } , $ indexNames ) ; } | Initializes indices for the given SearchableModel . |
23,860 | private function getAlgoliaRecordsFromSearchableModelArray ( array $ searchableModels ) { if ( empty ( $ searchableModels ) ) { throw new \ InvalidArgumentException ( 'The given array should not be empty' ) ; } $ arrayType = \ get_class ( $ searchableModels [ 0 ] ) ; $ this -> checkImplementsSearchableInterface ( $ arrayType ) ; return \ array_map ( function ( SearchableInterface $ searchableModel ) use ( $ arrayType ) { if ( ! $ searchableModel instanceof $ arrayType ) { throw new \ InvalidArgumentException ( 'The given array should not contain multiple different classes' ) ; } $ algoliaRecord = $ searchableModel -> getAlgoliaRecord ( ) ; $ algoliaRecord [ 'objectID' ] = $ searchableModel -> getObjectID ( ) ; return $ algoliaRecord ; } , $ searchableModels ) ; } | Maps an array of searchable models into an Algolia friendly array . |
23,861 | private function reindexAtomically ( Index $ index , array $ algoliaRecords ) { $ temporaryIndexName = 'tmp_' . $ index -> indexName ; $ temporaryIndex = $ this -> initIndex ( $ temporaryIndexName ) ; $ temporaryIndex -> addObjects ( $ algoliaRecords ) ; $ settings = $ index -> getSettings ( ) ; $ temporaryIndex -> setSettings ( $ settings ) ; return $ this -> moveIndex ( $ temporaryIndexName , $ index -> indexName ) ; } | Reindex atomically the given index with the given records . |
23,862 | private function processIndices ( $ indices , callable $ callback ) { $ response = [ ] ; foreach ( $ indices as $ index ) { $ response [ $ index -> indexName ] = \ call_user_func ( $ callback , $ index ) ; } return $ response ; } | Performs actions for given indices returning an array of responses from those actions . |
23,863 | public function withDir ( string $ dir ) : self { $ builder = clone $ this ; $ builder -> dir = $ dir ; return $ builder ; } | Set the working directory to be used by the process . |
23,864 | public function withEnv ( string $ name , string $ value ) : self { $ builder = clone $ this ; $ builder -> env [ $ name ] = $ value ; return $ builder ; } | Set an environment variable to be passed to the process . |
23,865 | public function start ( Context $ context , array $ args = [ ] ) : Promise { $ factory = $ context -> lookup ( ProcessFactory :: class ) ; if ( $ factory === null ) { throw new \ RuntimeException ( 'Cannot launch an async process without a process factory' ) ; } $ options = [ ] ; foreach ( $ this -> options as $ k => $ v ) { if ( \ strlen ( $ k ) === 1 ) { $ name = '-' . $ k ; } else { $ name = '--' . $ k ; } if ( $ v === null ) { $ options [ ] = $ name ; } else { foreach ( $ v as $ val ) { $ options [ ] = $ name ; $ options [ ] = $ val ; } } } return $ context -> task ( $ factory -> createProcess ( $ context , $ this -> command , \ array_merge ( $ options , $ args ) , $ this -> dir , $ this -> env ) ) ; } | Start an instance of the configured process . |
23,866 | public function run ( Context $ context , array $ args , ? callable $ stdin = null , ? callable $ stdout = null , ? callable $ stderr = null ) : Promise { static $ discard ; static $ closer ; if ( $ discard === null ) { $ discard = static function ( Context $ context , ReadableStream $ stream ) { yield $ stream -> discard ( $ context ) ; } ; } if ( $ closer === null ) { $ closer = static function ( Context $ context , ? callable $ callback , $ pipe ) { $ result = null ; try { if ( $ callback ) { $ result = yield from Coroutine :: generate ( $ callback , $ context , $ pipe ) ; } } finally { $ pipe -> close ( ) ; } return $ result ; } ; } return $ context -> task ( function ( Context $ context ) use ( $ args , $ stdin , $ stdout , $ stderr , $ closer , $ discard ) { $ process = yield $ this -> start ( $ context , $ args ) ; try { $ context = $ context -> cancellable ( $ cancel = $ context -> cancellationHandler ( ) ) ; yield $ context -> all ( [ $ closer ( $ context , $ stdin , $ process -> getStdin ( ) ) , $ closer ( $ context , $ stdout ?? $ discard , $ process -> getStdout ( ) ) , $ closer ( $ context , $ stderr ?? $ discard , $ process -> getStderr ( ) ) ] , $ cancel ) ; $ code = yield $ process -> exitCode ( $ context ) ; } finally { $ process -> close ( ) ; } return $ code ; } ) ; } | Run the configured process to completion using the given read and write handlers . |
23,867 | public static function charCount ( $ char ) : int { self :: handleIncomingChar ( $ char ) ; $ stringChar = ( string ) $ char ; return mb_ord ( $ stringChar , mb_detect_encoding ( $ stringChar ) ) > 0xFFFF ? 2 : 1 ; } | Determines the number of char values needed to represent the specified character |
23,868 | public static function codePointBefore ( $ chars , int $ index , int $ start = null ) : int { if ( $ start !== null && ( $ start < 0 || $ index <= $ start ) ) { throw new InvalidArgumentException ( 'Start cannot be negative and index must be greater than start!' ) ; } return static :: codePointAt ( $ chars , $ index - 1 ) ; } | Returns the unicode code point before specified index |
23,869 | public static function compare ( $ charA , $ charB ) : int { self :: handleIncomingChar ( $ charA , $ charB ) ; return ( string ) $ charA <=> ( string ) $ charB ; } | Compares specified characters numerically |
23,870 | private static function handleIncomingChar ( ... $ chars ) : void { foreach ( $ chars as $ char ) { Assert :: typeOf ( [ 'string' , __CLASS__ ] , $ char ) ; if ( mb_strlen ( ( string ) $ char ) !== 1 ) { throw new InvalidArgumentException ( 'Only one character can be represented!' ) ; } } } | Validates given character and throws an exception if required |
23,871 | public static function isLowerCase ( $ char ) : bool { self :: handleIncomingChar ( $ char ) ; return static :: compare ( $ char , static :: toLowerCase ( $ char ) ) === 0 ; } | Checks if specified character is lower case |
23,872 | public static function isUpperCase ( $ char ) : bool { self :: handleIncomingChar ( $ char ) ; return static :: compare ( $ char , static :: toUpperCase ( $ char ) ) === 0 ; } | Checks if specified character is upper case |
23,873 | public static function valueOf ( $ char ) : self { if ( \ is_string ( $ char ) || $ char instanceof self ) { return new static ( ( string ) $ char ) ; } throw new InvalidArgumentException ( 'Unsupported character type!' ) ; } | Returns specified value as character |
23,874 | public static function createBySizeName ( string $ name ) : self { $ registeredImageSizes = get_intermediate_image_sizes ( ) ; $ additionalImageSizes = wp_get_additional_image_sizes ( ) ; Assert :: oneOf ( $ name , $ registeredImageSizes , "{$name} size not found on WordPress registered sizes." ) ; if ( $ additionalImageSizes [ $ name ] ?? false ) { return new self ( ( int ) $ additionalImageSizes [ $ name ] [ 'width' ] , ( int ) $ additionalImageSizes [ $ name ] [ 'height' ] ) ; } return new self ( ( int ) get_option ( "{$name}_size_w" , null ) , ( int ) get_option ( "{$name}_size_h" , null ) ) ; } | Create a Size Instance by string WordPress style |
23,875 | public function update ( UpdateUserRequest $ request ) { $ this -> dispatch ( new UpdateUser ( $ this -> auth -> user ( ) -> id , $ request -> get ( 'name' ) , $ request -> get ( 'email' ) ) ) ; return redirect ( ) -> route ( 'authentication::profile.show' ) ; } | Attempts to update the user profile . |
23,876 | public function target ( $ target , $ keyName = null ) { $ this -> target = $ target ; $ this -> keyName = $ keyName ; return $ this ; } | Which type of annotation should the reader target . The default is class . |
23,877 | public function read ( $ argument ) { $ reflection = $ this -> getReflectionFrom ( $ argument ) ; if ( $ this -> wantsSpecificAnnotation ( ) ) { return $ this -> readSpecificAnnotationFor ( $ reflection ) ; } return $ this -> readAllAnnotationsFor ( $ reflection ) ; } | Reads annotations for a given object . |
23,878 | public function addFilesToRegistry ( $ filePaths ) { collect ( ( array ) $ filePaths ) -> each ( function ( $ filePath ) { if ( file_exists ( $ filePath ) ) { AnnotationRegistry :: registerFile ( $ filePath ) ; } } ) ; return $ this ; } | Adds files containing annotations to the registry . |
23,879 | public function addNamespacesToRegistry ( $ namespaces ) { collect ( ( array ) $ namespaces ) -> each ( function ( $ namespace ) { $ path = $ this -> getPathFromNamespace ( $ namespace ) ; if ( file_exists ( $ path ) ) { foreach ( Finder :: create ( ) -> files ( ) -> name ( '*.php' ) -> in ( $ path ) as $ file ) { $ this -> addFilesToRegistry ( $ file -> getRealPath ( ) ) ; } } } ) ; return $ this ; } | Adds namespaces containing annotations to the registry . |
23,880 | protected function readAllAnnotationsFor ( $ reflection ) { $ methodName = $ this -> constructReadMethod ( ) ; return collect ( $ this -> reader -> { $ methodName } ( $ reflection ) ) ; } | Reads all the annotations for the given target . |
23,881 | protected function readSpecificAnnotationFor ( $ reflection ) { $ methodName = $ this -> constructReadMethod ( ) ; return collect ( $ this -> reader -> { $ methodName } ( $ reflection , $ this -> annotationName ) ) ; } | Reads the specified annotation name given for the target . |
23,882 | protected function getReflectionFrom ( $ argument ) { $ reflectionMethodName = Str :: camel ( 'getreflection' . $ this -> target . 'from' ) ; return $ this -> { $ reflectionMethodName } ( $ argument ) ; } | Get the ReflectionClass from an argument . be it an object or a class name . |
23,883 | protected function getReflectionPropertyFrom ( $ argument ) { if ( is_null ( $ this -> keyName ) ) { throw new InvalidArgumentException ( 'Property name to target is required' ) ; } if ( is_object ( $ argument ) ) { $ argument = get_class ( $ argument ) ; } return new ReflectionProperty ( $ argument , $ this -> keyName ) ; } | Get the ReflectionProperty for a given argument . |
23,884 | protected function getReflectionMethodFrom ( $ argument ) { if ( is_null ( $ this -> keyName ) ) { throw new InvalidArgumentException ( 'Method name to target is required' ) ; } if ( is_object ( $ argument ) ) { $ argument = get_class ( $ argument ) ; } return new ReflectionMethod ( $ argument , $ this -> keyName ) ; } | Get the ReflectionMethod for a given argument . |
23,885 | protected function constructReadMethod ( ) { $ endsWith = 'annotations' ; if ( $ this -> wantsSpecificAnnotation ( ) ) { $ endsWith = 'annotation' ; } return Str :: camel ( 'get' . $ this -> target . $ endsWith ) ; } | Gets the Method name to be used by the Reader . |
23,886 | public function restoreSorting ( array $ scope = [ ] ) : void { $ records = $ this -> _table -> find ( ) -> select ( [ $ this -> _table -> getPrimaryKey ( ) , $ this -> getConfig ( 'sortField' ) ] ) -> select ( $ this -> getConfig ( 'columnScope' ) ) -> order ( $ this -> getConfig ( 'defaultOrder' ) ) ; if ( ! empty ( $ scope ) ) { $ records -> where ( $ scope ) ; } $ sorts = [ ] ; foreach ( $ records as $ entity ) { $ individualScope = '' ; foreach ( $ this -> getConfig ( 'columnScope' ) as $ column ) { $ individualScope .= $ entity -> get ( $ column ) ; } if ( ! isset ( $ sorts [ $ individualScope ] ) ) { $ sorts [ $ individualScope ] = 0 ; } $ sort = ++ $ sorts [ $ individualScope ] ; $ this -> _table -> updateAll ( [ $ this -> getConfig ( 'sortField' ) => $ sort , ] , [ $ this -> _table -> getPrimaryKey ( ) => $ entity -> get ( $ this -> _table -> getPrimaryKey ( ) ) , ] ) ; } } | Restores the sorting based on defaultOrder |
23,887 | public function getNextSortValue ( array $ scope = [ ] ) : int { $ query = $ this -> _table -> query ( ) ; $ scope = Hash :: merge ( $ this -> getConfig ( 'scope' ) , $ scope ) ; if ( ! empty ( $ scope ) ) { $ query -> where ( $ scope ) ; } $ query -> select ( [ 'maxSort' => $ query -> func ( ) -> max ( $ this -> getConfig ( 'sortField' ) ) , ] ) ; $ res = $ query -> enableHydration ( false ) -> first ( ) ; if ( empty ( $ res ) ) { return 1 ; } return ( $ res [ 'maxSort' ] + 1 ) ; } | Returns the next highest sort value |
23,888 | private function makeArraySerializable ( array $ data ) { $ serializable = [ ] ; foreach ( $ data as $ key => $ value ) { if ( is_object ( $ value ) ) { $ serializable [ $ key ] = new ObjectStub ( $ value ) ; continue ; } $ serializable [ $ key ] = is_array ( $ value ) ? $ this -> makeArraySerializable ( $ value ) : $ value ; } return $ serializable ; } | Replaces the un - serializable items in an array with stubs |
23,889 | private function createElasticSearchQuery ( array $ params , $ operator = 'AND' ) { $ filteredParams = [ ] ; foreach ( $ params as $ name => $ value ) { if ( empty ( $ name ) || empty ( $ value ) ) { continue ; } $ filteredParams [ ] = "$name:$value" ; } return implode ( " $operator " , $ filteredParams ) ; } | Creates an elastic search query from the provided array od parameters . |
23,890 | private function normalizeSearchChannelsResponse ( $ response ) { $ response = json_decode ( $ response , true ) ; if ( ! is_array ( $ response ) || ! array_key_exists ( 'result' , $ response ) || ! array_key_exists ( 'total' , $ response ) ) { throw new Exception ( 'Invalid response from search endpoint' ) ; } $ response [ 'totalCount' ] = $ response [ 'total' ] ; $ response [ 'channels' ] = $ response [ 'result' ] ; unset ( $ response [ 'result' ] , $ response [ 'total' ] ) ; return json_encode ( $ response ) ; } | Adjust the response from the search endpoint for channel data type . Namely it renames the root - level properties so they can be correctly unserialized . |
23,891 | public function createFetch ( $ params , $ optParams = [ ] ) { if ( is_string ( $ params ) ) { $ params = [ 'url' => $ params ] ; } $ params = $ this -> client -> fillParams ( [ 'cloudId' , 'url' ] , $ params ) ; return $ this -> build ( '/f/' . $ params [ 'url' ] , $ params , $ optParams ) ; } | Creates the fetch URL for a remote image . |
23,892 | public function createFacebook ( $ params , $ optParams = [ ] ) { if ( is_string ( $ params ) ) { $ params = [ 'facebookId' => $ params ] ; } $ params = $ this -> client -> fillParams ( [ 'cloudId' , 'facebookId' ] , $ params ) ; return $ this -> build ( '/r/facebook/' . $ params [ 'facebookId' ] , $ params , $ optParams ) ; } | Creates the URL for a Facebook profile picture . |
23,893 | public function createTwitter ( $ params , $ optParams = [ ] ) { if ( is_string ( $ params ) ) { $ params = [ 'twitterId' => $ params ] ; } $ params = $ this -> client -> fillParams ( [ 'cloudId' , 'twitterId' ] , $ params ) ; return $ this -> build ( '/r/twitter/' . $ params [ 'twitterId' ] , $ params , $ optParams ) ; } | Creates the URL for a Twitter profile picture . |
23,894 | public function createYoutube ( $ params , $ optParams = [ ] ) { if ( is_string ( $ params ) ) { $ params = [ 'youtubeId' => $ params ] ; } $ params = $ this -> client -> fillParams ( [ 'cloudId' , 'youtubeId' ] , $ params ) ; return $ this -> build ( '/r/youtube/' . $ params [ 'youtubeId' ] , $ params , $ optParams ) ; } | Creates the URL for a YouTube video preview image . |
23,895 | public function createCloudinary ( $ params , $ optParams = [ ] ) { $ params = $ this -> client -> fillParams ( [ 'cloudId' , 'cloudinaryCloud' , 'cloudinaryImage' ] , $ params ) ; return $ this -> build ( '/r/cloudinary/' . urlencode ( $ params [ 'cloudinaryCloud' ] . '/' . $ params [ 'cloudinaryImage' ] ) , $ params , $ optParams ) ; } | Creates the URL for a Cloudinary image . |
23,896 | public function createWikimedia ( $ params , $ optParams = [ ] ) { if ( is_string ( $ params ) ) { $ params = [ 'wikimediaImage' => $ params ] ; } $ params = $ this -> client -> fillParams ( [ 'cloudId' , 'wikimediaImage' ] , $ params ) ; return $ this -> build ( '/r/commons/' . urlencode ( $ params [ 'wikimediaImage' ] ) , $ params , $ optParams ) ; } | Creates the URL for a Wikimedia commons image . |
23,897 | private function build ( $ resource , $ params , $ optParams ) { $ url = '' ; if ( isset ( $ optParams [ 'option' ] ) ) { $ option = ( string ) $ optParams [ 'option' ] ; if ( ! empty ( $ option ) ) { $ url .= '/o-' . $ option ; } } if ( isset ( $ optParams [ 'transformation' ] ) ) { $ transformation = ( string ) $ optParams [ 'transformation' ] ; if ( ! empty ( $ transformation ) ) { $ url .= '/' . trim ( $ transformation , '/' ) ; } } if ( isset ( $ optParams [ 'version' ] ) ) { $ url .= '/v/' . $ optParams [ 'version' ] ; } $ url .= $ resource ; if ( isset ( $ optParams [ 'format' ] ) ) { $ url .= '.' . $ optParams [ 'format' ] ; } if ( isset ( $ optParams [ 'seo' ] ) ) { $ url .= '/seo/' . $ optParams [ 'seo' ] ; } $ security = '' ; if ( isset ( $ optParams [ 'security' ] ) ) { switch ( $ optParams [ 'security' ] ) { case 'basic' : if ( ! $ this -> client -> apiKey || ! $ this -> client -> imageSecret ) { throw new InvalidConfigException ( 'The apiKey and imageSecret must be specified!' ) ; } $ security = '/s-b3:' . SecurityHelper :: generateImageSecretSignature ( $ this -> client -> imageHostname , ltrim ( $ url , '/' ) , $ this -> client -> apiKey , $ this -> client -> imageSecret ) ; break ; case 'token' : if ( ! $ this -> client -> apiAccessTokenSecret ) { throw new InvalidConfigException ( 'The apiAccessTokenSecret must be specified!' ) ; } $ security = '/s-token:' . $ this -> client -> apiAccessToken . ',' . SecurityHelper :: generateTokenHash ( $ this -> client -> imageHostname , ltrim ( $ url , '/' ) , $ this -> client -> apiAccessToken , $ this -> client -> apiAccessTokenSecret ) ; break ; } } return $ this -> client -> imageHost . '/' . $ params [ 'cloudId' ] . $ security . $ url ; } | Builds the URL . |
23,898 | function find ( $ logicalPath , $ options = array ( ) ) { $ path = new FileUtils \ PathInfo ( $ logicalPath ) ; if ( $ path -> isAbsolute ( ) ) { $ realPath = $ logicalPath ; } else { $ realPath = $ this -> loadPaths -> find ( $ logicalPath ) ; } if ( ! is_file ( $ realPath ) ) { return ; } if ( null === $ realPath ) { return ; } if ( @ $ options [ "bundled" ] ) { $ asset = new BundledAsset ( $ this , $ realPath , $ logicalPath ) ; } else { $ asset = new ProcessedAsset ( $ this , $ realPath , $ logicalPath ) ; } return $ asset ; } | Finds the logical path in the stack of load paths and returns the Asset . |
23,899 | function logicalPath ( $ absolutePath ) { foreach ( $ this -> loadPaths -> paths ( ) as $ lp ) { $ absoluteLoadPath = realpath ( $ lp ) ; if ( strpos ( $ absolutePath , $ absoluteLoadPath ) === 0 ) { return ltrim ( substr ( $ absolutePath , strlen ( $ absoluteLoadPath ) ) , '/' ) ; } } } | Calculates the logical path for the given absolute path |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.