idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
35,100 | public function lower ( $ column , $ value , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ Basic ( $ column , '<' , $ value , $ conjunction ) ) ; } | Asserts that the column is lower then the value |
35,101 | public function lowerThen ( $ column , $ value , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ Basic ( $ column , '<=' , $ value , $ conjunction ) ) ; } | Asserts that the column is lower or equal to the value |
35,102 | public function like ( $ column , $ value , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ Basic ( $ column , 'LIKE' , $ value , $ conjunction ) ) ; } | Asserts that the column is like the value |
35,103 | public function notLike ( $ column , $ value , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ Basic ( $ column , 'NOT LIKE' , $ value , $ conjunction ) ) ; } | Asserts that the column is not like the value |
35,104 | public function between ( $ column , $ left , $ right , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ Between ( $ column , $ left , $ right , $ conjunction ) ) ; } | Asserts that the column is between the left and right value |
35,105 | public function in ( $ column , array $ values , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ In ( $ column , $ values , $ conjunction ) ) ; } | Asserts that the column is in the array of values |
35,106 | public function raw ( $ statment , array $ values = array ( ) , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ Raw ( $ statment , $ values , $ conjunction ) ) ; } | Adds an raw SQL expression |
35,107 | public function regexp ( $ column , $ regexp , $ conjunction = 'AND' ) { return $ this -> addExpression ( new Condition \ Regexp ( $ column , $ regexp , $ conjunction ) ) ; } | Asserts that the column matches the provided regular expression |
35,108 | public function merge ( Condition $ condition ) { $ this -> expressions = array_merge ( $ this -> expressions , $ condition -> toArray ( ) ) ; return $ this ; } | Merges an existing condition |
35,109 | public function get ( $ column ) { foreach ( $ this -> expressions as $ expr ) { if ( $ expr -> getColumn ( ) == $ column ) { return $ expr ; } } return null ; } | Returns an expression by the column name or null |
35,110 | public function remove ( $ column ) { foreach ( $ this -> expressions as $ key => $ expr ) { if ( $ expr -> getColumn ( ) == $ column ) { unset ( $ this -> expressions [ $ key ] ) ; } } } | Removes an condition containing an specific column |
35,111 | public function getExpression ( AbstractPlatform $ platform ) { $ len = count ( $ this -> expressions ) ; $ con = '' ; $ i = 0 ; if ( empty ( $ this -> expressions ) ) { return $ this -> isInverse ? '1 = 0' : '1 = 1' ; } foreach ( $ this -> expressions as $ key => $ expr ) { $ con .= $ expr -> getExpression ( $ platform ) ; $ con .= ( $ i == $ len - 1 ) ? '' : ' ' . $ expr -> getConjunction ( ) . ' ' ; $ i ++ ; } return ( $ this -> isInverse ? '!' : '' ) . '(' . $ con . ')' ; } | Returns the SQL as string containing prepared statment placeholder |
35,112 | public function getValues ( ) { $ params = array ( ) ; foreach ( $ this -> expressions as $ expr ) { $ values = $ expr -> getValues ( ) ; foreach ( $ values as $ value ) { if ( $ value instanceof \ DateTime ) { $ params [ ] = $ value -> format ( 'Y-m-d H:i:s' ) ; } else { $ params [ ] = $ value ; } } } return $ params ; } | Returns the parameters as array |
35,113 | private function processCreateMigration ( $ name , $ fields ) { $ this -> migrationService -> processCommand ( 'create' , $ name ) ; foreach ( $ fields as $ fieldDefinition ) { $ fieldDefinition = explode ( ':' , $ fieldDefinition ) ; $ fieldDefinition = array_map ( function ( $ value ) { return ( strlen ( $ value ) === 0 ? NULL : $ value ) ; } , $ fieldDefinition ) ; $ this -> migrationService -> processCommand ( 'addColumn' , ... $ fieldDefinition ) ; } $ this -> migrationService -> processCommand ( 'finalise' ) ; $ this -> migrationService -> create ( $ name ) ; } | Processes the fields to create the migration |
35,114 | private function processCreateModel ( $ name , $ fields ) { foreach ( $ fields as $ fieldDefinition ) { $ fieldDefinition = explode ( ':' , $ fieldDefinition ) ; $ this -> modelService -> processCommand ( 'addColumn' , ... $ fieldDefinition ) ; } $ this -> modelService -> create ( $ name ) ; } | Process the fields to create the model! |
35,115 | private function processCreateDI ( $ name ) { $ this -> dependencyService -> processCommand ( 'injectModel' , $ name ) ; $ this -> dependencyService -> create ( $ name ) ; } | Create any dependency injection entries |
35,116 | public function generate ( $ where , string $ name = null ) { $ model = ( static :: MODEL_CLASS ) :: getInstance ( $ where ) ; if ( $ model === null ) { return false ; } $ view = static :: getView ( $ model ) ; $ this -> views [ ] = [ 'file' => $ view , 'name' => BankInterchange \ Utils :: addExtension ( $ name ?? $ view -> filename ( ) , static :: EXTENSION ) , ] ; return true ; } | Generates the file View from data in a Medools Model |
35,117 | public function output ( ) { $ count = count ( $ this -> views ) ; if ( $ count === 0 ) { throw new \ LogicException ( 'You need to generate() first' ) ; } elseif ( $ count > 1 ) { return $ this -> zip ( ) ; } $ view = $ this -> views [ 0 ] ; $ view [ 'file' ] -> outputFile ( $ view [ 'name' ] ) ; } | Outputs the View with appropriated headers |
35,118 | public function zip ( string $ name = null ) { if ( count ( $ this -> views ) === 0 ) { throw new \ LogicException ( 'You need to generate() first' ) ; } Utils :: checkOutput ( 'ZIP' ) ; $ file = tmpfile ( ) ; $ filepath = stream_get_meta_data ( $ file ) [ 'uri' ] ; $ zip = new \ ZipArchive ( ) ; $ zip -> open ( $ filepath , \ ZipArchive :: OVERWRITE ) ; foreach ( $ this -> views as $ view ) { $ zip -> addFromString ( $ view [ 'name' ] , $ view [ 'file' ] -> getContents ( ) ) ; } $ zip -> close ( ) ; $ name = BankInterchange \ Utils :: addExtension ( $ name ?? 'download' , '.zip' ) ; header ( 'Content-Type: application/zip' ) ; header ( 'Content-Length: ' . filesize ( $ filepath ) ) ; header ( 'Content-Disposition: attachment; filename="' . $ name . '"' ) ; readfile ( $ filepath ) ; unlink ( $ filepath ) ; } | Outputs a zip file containing all views |
35,119 | public function isEqualTo ( BaseUserInterface $ user ) : bool { if ( $ user instanceof self && $ this -> apiUser instanceof APIUser ) { return $ user -> getAPIUser ( ) -> id === $ this -> apiUser -> id ; } return false ; } | Compares the users . |
35,120 | public function delivery ( Money $ delivery ) { if ( $ this -> price -> isSameCurrency ( $ delivery ) ) { $ this -> delivery = $ delivery ; } } | Set the delivery charge |
35,121 | public function category ( Category $ category ) { $ this -> category = $ category ; $ this -> category -> categorise ( $ this ) ; } | Set a category |
35,122 | public function create ( $ table , $ schema ) { return $ this -> destroy ( $ schema , $ table ) -> initialize ( $ schema , $ table ) ; } | Creates the underlying tables for a schema dropping any tables of the same names |
35,123 | public function initialize ( $ schema , $ table = null ) { $ mapper = $ this -> _mapper ( $ schema ) ; $ table = $ table ? $ this -> _connection ( $ schema ) -> table ( $ table ) : $ mapper -> table ( ) ; $ sequencePool = $ this -> _connection ( $ schema ) -> sequencePool ( ) ; $ sequencePool -> initialize ( ) ; $ columns = array ( ) ; foreach ( $ schema -> properties ( ) as $ prop ) { $ columns [ $ prop -> name ] = $ prop -> type ; if ( property_exists ( $ prop -> type , 'sequence' ) ) { $ sequencePool -> delete ( $ mapper -> sequenceName ( $ prop ) ) ; } } $ table -> create ( $ columns ) ; return $ this ; } | Sets up an tables and sequences for a Schema |
35,124 | public function destroy ( $ schema , $ table = null ) { $ mapper = $ this -> _mapper ( $ schema ) ; $ table = $ table ? $ this -> _connection ( $ schema ) -> table ( $ table ) : $ mapper -> table ( ) ; $ sequencePool = $ this -> _connection ( $ schema ) -> sequencePool ( ) ; $ sequencePool -> initialize ( ) ; foreach ( $ schema -> properties ( ) as $ prop ) { if ( property_exists ( $ prop -> type , 'sequence' ) ) { $ sequencePool -> delete ( $ mapper -> sequenceName ( $ prop ) ) ; } } $ table -> dropIfExists ( ) ; return $ this ; } | Destroy tables and sequences for a Schema |
35,125 | public function usernameExists ( $ userName ) { $ existing = $ this -> em -> getRepository ( User :: class ) -> findOneBy ( [ 'username' => $ userName , ] ) ; return ( bool ) $ existing ; } | Check if a username is already in use |
35,126 | public function addCryptoNode ( $ type ) { $ nodeName = $ type . 'ion' ; $ treeBuilder = new TreeBuilder ( $ nodeName ) ; $ rootNode = $ this -> getRootNodeFromTreeBuilder ( $ treeBuilder , $ nodeName ) ; $ rootNode -> info ( 'Configure ' . $ type . 'er.' ) -> isRequired ( ) -> fixXmlConfig ( 'argument' ) -> children ( ) -> scalarNode ( 'service' ) -> info ( 'Symfony service name of ' . $ type . 'er.' ) -> isRequired ( ) -> cannotBeEmpty ( ) -> end ( ) -> arrayNode ( 'key' ) -> info ( ucfirst ( $ type ) . 'ion key settings.' ) -> beforeNormalization ( ) -> ifTrue ( function ( $ v ) { return \ is_string ( $ v ) ; } ) -> then ( function ( $ v ) { return [ 'value' => $ v ] ; } ) -> end ( ) -> addDefaultsIfNotSet ( ) -> children ( ) -> scalarNode ( 'value' ) -> info ( 'Either the key or a password to use for key generation.' ) -> defaultValue ( '' ) -> end ( ) -> booleanNode ( 'base64_encoded' ) -> info ( 'Key / password (value) is base64 encoded.' ) -> defaultFalse ( ) -> end ( ) -> scalarNode ( 'type' ) -> info ( 'Key type.' ) -> cannotBeEmpty ( ) -> defaultValue ( StaticKeyType :: TYPE_NAME ) -> end ( ) -> scalarNode ( 'method' ) -> info ( 'Generated key: generation method.' ) -> cannotBeEmpty ( ) -> defaultValue ( 'pbkdf2' ) -> end ( ) -> scalarNode ( 'hash_algorithm' ) -> info ( 'Generated key: hash algorithm.' ) -> cannotBeEmpty ( ) -> end ( ) -> scalarNode ( 'salt' ) -> info ( 'Generated key: salt.' ) -> cannotBeEmpty ( ) -> end ( ) -> integerNode ( 'cost' ) -> info ( 'Generated key: cost.' ) -> min ( 1 ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) ; return $ rootNode ; } | Add crypto node . |
35,127 | private function getRootNodeFromTreeBuilder ( TreeBuilder $ treeBuilder , string $ nodeName ) : NodeDefinition { return ( method_exists ( $ treeBuilder , 'getRootNode' ) ? $ treeBuilder -> getRootNode ( ) : $ treeBuilder -> root ( $ nodeName ) ) ; } | Get root node from tree builder . |
35,128 | private function areMultipleNamespacesInFile ( ) { if ( count ( $ this -> objects ) === 0 ) { return false ; } $ foundNamespaces = array ( ) ; foreach ( $ this -> objects as $ object ) { $ ns = $ object -> getNamespace ( ) ; if ( $ ns !== null ) { $ foundNamespaces [ $ ns ] = $ ns ; } } $ foundNamespacesCount = count ( $ foundNamespaces ) ; if ( $ foundNamespacesCount === 0 ) { return false ; } elseif ( $ foundNamespacesCount > 1 ) { return true ; } else { return ! isset ( $ foundNamespaces [ $ this -> getNamespace ( ) ] ) ; } } | Check if there are multiple namespaces in the file . |
35,129 | private function renderRequiredFilesLines ( ) { $ code = array ( ) ; $ indentation = $ this -> getIndentation ( ) ; foreach ( $ this -> requiredFiles as $ requiredFile ) { $ code [ ] = $ indentation . "require_once ('" . $ requiredFile . "');" ; } if ( count ( $ this -> requiredFiles ) > 0 ) { $ code [ ] = null ; } return $ code ; } | Render the required files . |
35,130 | private function renderObjects ( $ withNamespace ) { $ code = array ( ) ; foreach ( $ this -> getObjects ( ) as $ object ) { $ originalUses = $ object -> getUses ( ) ; $ object -> setUses ( array ( ) ) ; if ( $ withNamespace === false ) { $ originalNamespace = $ object -> getNamespace ( ) ; $ object -> setNamespace ( null ) ; $ code [ ] = $ object -> generate ( ) ; $ object -> setNamespace ( $ originalNamespace ) ; } else { $ code [ ] = $ object -> generate ( ) ; } $ object -> setUses ( $ originalUses ) ; $ code [ ] = null ; } return $ code ; } | Render all the objects . |
35,131 | public function acquire ( ) { if ( ! $ this -> _object -> isSaved ( ) ) { throw new LockingException ( "Can't lock unsaved objects" ) ; } $ finder = \ Pheasant :: instance ( ) -> finderFor ( $ this -> _object ) ; return $ freshObject = $ finder -> find ( $ this -> _object -> className ( ) , $ this -> _object -> identity ( ) -> toCriteria ( ) ) -> lock ( $ this -> _clause ) -> one ( ) ; } | Acquire the lock on the object |
35,132 | private function getAllowedMethods ( ServerRequestInterface $ request ) : array { $ allowed = [ ] ; $ requestPath = $ request -> getUri ( ) -> getPath ( ) ; foreach ( Method :: all ( ) as $ method ) { $ matchThis = "$requestPath{}$method" ; if ( preg_match ( $ this -> pattern , $ matchThis , $ matches ) === 1 ) { $ allowed [ $ method ] = $ this -> getRoute ( $ matches ) ; } } return $ allowed ; } | Get an array of allowed methods and their routes . |
35,133 | public function searchRouteAction ( $ context ) { $ searchAdapter = $ this -> get ( 'netgen_search_and_filter.route_' . $ context ) ; $ form = $ searchAdapter -> getForm ( ) ; $ response = new Response ( ) ; $ pager = new Pagerfanta ( $ searchAdapter ) ; $ pager -> setMaxPerPage ( $ searchAdapter -> getPageLimit ( ) ) ; $ showResults = $ this -> getPage ( $ pager , $ form ) ; $ request = $ this -> container -> get ( 'request' ) ; return $ this -> render ( $ searchAdapter -> getResultTemplate ( ) , array ( 'pagelayout' => $ this -> container -> getParameter ( "netgen_search_and_filter.main_pagelayout" ) , 'route' => $ request -> get ( '_route' ) , 'context' => $ context , 'form_template' => $ searchAdapter -> getFormTemplate ( ) , 'form' => $ form -> createView ( ) , 'pager' => $ pager , 'show_results' => $ showResults , 'query_string' => array ( $ form -> getName ( ) => $ form -> getData ( ) ) , 'current_locale' => $ this -> getConfigResolver ( ) -> getParameter ( 'RegionalSettings.Locale' ) ) , $ response ) ; } | Action for rendering search page for Route |
35,134 | public function searchLocationAction ( $ locationId , $ viewType , $ layout = false , array $ params = array ( ) ) { $ repository = $ this -> getRepository ( ) ; $ location = $ repository -> getLocationService ( ) -> loadLocation ( $ locationId ) ; try { $ searchAdapter = $ this -> get ( 'netgen_search_and_filter.location_' . $ locationId ) ; } catch ( ServiceNotFoundException $ e ) { return $ this -> get ( 'ez_content' ) -> viewLocation ( $ locationId , $ viewType , $ layout , $ params ) ; } $ form = $ searchAdapter -> getForm ( ) ; $ response = new Response ( ) ; $ response -> headers -> set ( 'X-Location-Id' , $ locationId ) ; $ response -> setVary ( 'X-User-Hash' ) ; $ pager = new Pagerfanta ( $ searchAdapter ) ; $ pager -> setMaxPerPage ( $ searchAdapter -> getPageLimit ( ) ) ; $ showResults = $ this -> getPage ( $ pager , $ form ) ; return $ this -> render ( $ searchAdapter -> getResultTemplate ( ) , array ( 'pagelayout' => $ this -> container -> getParameter ( "netgen_search_and_filter.main_pagelayout" ) , 'form_template' => $ searchAdapter -> getFormTemplate ( ) , 'form' => $ form -> createView ( ) , 'location' => $ location , 'content' => $ repository -> getContentService ( ) -> loadContentByContentInfo ( $ location -> getContentInfo ( ) ) , 'pager' => $ pager , 'show_results' => $ showResults , 'query_string' => array ( $ form -> getName ( ) => $ form -> getData ( ) ) , 'current_locale' => $ this -> getConfigResolver ( ) -> getParameter ( 'RegionalSettings.Locale' ) ) , $ response ) ; } | Action for rendering search page for Location |
35,135 | public function getPage ( $ pager , $ form ) { $ showResults = false ; if ( $ this -> getRequest ( ) -> isMethod ( "POST" ) ) { $ form -> handleRequest ( $ this -> getRequest ( ) ) ; if ( $ form -> isValid ( ) ) { $ pager -> setCurrentPage ( $ this -> getRequest ( ) -> get ( 'page' , 1 ) ) ; $ showResults = true ; } } else { $ data = $ this -> getRequest ( ) -> query -> all ( ) ; if ( array_key_exists ( $ form -> getName ( ) , $ data ) ) { $ form -> setData ( $ data [ $ form -> getName ( ) ] ) ; if ( is_numeric ( $ this -> getRequest ( ) -> query -> get ( "page" ) ) ) { $ pager -> setCurrentPage ( $ this -> getRequest ( ) -> get ( 'page' , $ this -> getRequest ( ) -> query -> get ( "page" ) ) ) ; $ showResults = true ; } } } return $ showResults ; } | handles request sets the page gets data for the page returns boolean to show or not the results |
35,136 | public function render ( Render $ renderer ) { $ elements = '' ; foreach ( $ this -> getContents ( ) as $ element ) { $ elements .= "\n" . $ renderer -> render ( $ element ) ; } return Html :: tag ( 'form' , $ this -> getAttributes ( ) , $ elements ) ; } | Should return a html string that represents the rendered object |
35,137 | public function render ( Renderable $ element ) { $ className = $ this -> getClassName ( $ element ) ; $ functionName = static :: $ methodPrefix . $ className ; $ callName = '' ; $ is_container = $ element instanceof Form ; if ( $ is_container ) { $ this -> csrfProvider -> insertTokenPreRender ( $ element ) ; } if ( is_callable ( [ $ this , $ functionName ] , false , $ callName ) ) { $ result = $ this -> { $ functionName } ( $ element ) ; } else { $ inputRenderFunction = static :: $ methodPrefix . 'Input' ; $ inputRender = [ $ this , $ inputRenderFunction ] ; if ( is_callable ( $ inputRender ) ) { $ result = $ this -> $ inputRenderFunction ( $ element ) ; } else { $ elementRender = [ $ element , 'render' ] ; if ( is_callable ( $ elementRender ) ) { $ result = $ element -> render ( $ this ) ; } else { throw new \ InvalidArgumentException ( 'Unable to find a render method for ' . get_class ( $ element ) ) ; } } } if ( $ is_container ) { $ this -> csrfProvider -> insertTokenPostRender ( $ result ) ; } return $ result ; } | This is the main render function that will work what function from the subclass to call to render the given object . |
35,138 | protected function getClassName ( $ object ) { if ( is_object ( $ object ) ) { $ object = get_class ( $ object ) ; } $ nameArray = explode ( '\\' , $ object ) ; return array_pop ( $ nameArray ) ; } | Gets the base class name . |
35,139 | public function fetchTypes ( ) { $ response = $ this -> client -> request ( 'GET' , 'https://crest-tq.eveonline.com/market/types/' ) ; return iterator_to_array ( $ this -> getOtherPages ( json_decode ( $ response -> getBody ( ) -> getContents ( ) ) ) ) ; } | Fetches the market types . |
35,140 | public function getPayload ( ) { if ( ! $ this -> token ) { throw new \ RuntimeException ( 'Token is mandatory.' ) ; } $ descriptionNode = $ this -> appendDescriptionNode ( ) ; $ this -> appendTagNode ( $ descriptionNode ) ; $ this -> appendTokenNode ( $ descriptionNode ) ; $ this -> appendTemplateNode ( $ descriptionNode ) ; $ this -> appendAdditionalNode ( $ descriptionNode ) ; $ this -> dom -> formatOutput = true ; return $ this -> dom -> saveXML ( ) ; } | Returns the atom payload for the registration request . |
35,141 | protected function appendDescriptionNode ( ) { if ( $ this -> template ) { $ descriptionTag = $ this -> getTemplateRegistrationDescriptionTag ( ) ; } else { $ descriptionTag = $ this -> getRegistrationDescriptionTag ( ) ; } $ descriptionElement = $ this -> dom -> createElement ( $ descriptionTag ) ; $ descriptionElement -> setAttribute ( 'xmlns:i' , 'http://www.w3.org/2001/XMLSchema-instance' ) ; $ descriptionElement -> setAttribute ( 'xmlns' , 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect' ) ; return $ this -> content -> appendChild ( $ descriptionElement ) ; } | Appends the registration description DOMNode . |
35,142 | protected function appendTagNode ( $ descriptionNode ) { if ( $ this -> tags ) { $ descriptionNode -> appendChild ( $ this -> dom -> createElement ( 'Tags' , $ this -> getTags ( ) ) ) ; } } | Appends the Tags DOMNode . |
35,143 | protected function appendTokenNode ( $ descriptionNode ) { $ descriptionNode -> appendChild ( $ this -> dom -> createElement ( $ this -> getTokenTag ( ) , $ this -> token ) ) ; } | Appends the token DOMNode . |
35,144 | protected function appendTemplateNode ( $ descriptionNode ) { if ( $ this -> template ) { $ cdata = $ this -> dom -> createCDATASection ( $ this -> template ) ; $ bodyTemplateElement = $ this -> dom -> createElement ( 'BodyTemplate' ) ; $ bodyTemplateElement -> appendChild ( $ cdata ) ; $ descriptionNode -> appendChild ( $ bodyTemplateElement ) ; } } | Appends the BodyTemplate DOMNode . |
35,145 | public function startManipulation ( ) { $ core = ConfigurationManager :: Get ( "profiles.{$this->getProfileName()}.coreDirectory" ) ; $ public = ConfigurationManager :: Get ( "profiles.{$this->getProfileName()}.publicDirectory" ) ; $ manipulations = ConfigurationManager :: Get ( "profiles.{$this->getProfileName()}.manipulations" ) ; $ this -> fixBootstrapper ( $ public , $ core ) ; foreach ( $ manipulations as $ file => $ lines ) { $ file = Utility :: renderTemplate ( $ file , [ '{CORE}' => Utility :: getCorePath ( $ this -> getAlias ( ) , $ core ) , '{PUBLIC}' => Utility :: getPublicPath ( $ this -> getAlias ( ) , $ public ) ] ) ; $ file = Utility :: normalizePath ( $ file ) ; if ( \ file_exists ( $ file ) ) { Utility :: replaceInFile ( $ file , $ lines ) ; } } } | start code manipulation |
35,146 | protected function fixBootstrapper ( $ public , $ core ) { $ _core = Utility :: getCorePath ( $ this -> getAlias ( ) , $ core ) ; $ _public = Utility :: getPublicPath ( $ this -> getAlias ( ) , $ public ) ; $ core = Utility :: findRelativePath ( $ _public , $ _core ) ; $ indexPath = Utility :: combinePath ( Utility :: getPublicPath ( $ this -> getAlias ( ) , $ public ) , 'index.php' ) ; $ autoLoader = \ file_get_contents ( __DIR__ . '/../Stubs/autoLoader.tpl' ) ; $ autoLoader = Utility :: renderTemplate ( $ autoLoader , [ '{{CORE_PATH}}' => $ core ] ) ; $ autoLoader = Utility :: normalizePath ( $ autoLoader ) ; $ bootstrapper = \ file_get_contents ( __DIR__ . '/../Stubs/bootstrapper.tpl' ) ; $ bootstrapper = Utility :: renderTemplate ( $ bootstrapper , [ '{{CORE_PATH}}' => $ core ] ) ; $ bootstrapper = Utility :: normalizePath ( $ bootstrapper ) ; Utility :: replaceInFile ( $ indexPath , [ 'require __DIR__.\'/../bootstrap/autoload.php\';' => $ autoLoader , '$app = require_once __DIR__.\'/../bootstrap/app.php\';' => $ bootstrapper ] ) ; } | fixing laravel bootstrapper |
35,147 | public function getCompanies ( $ id = null , $ name = null , $ domain = null , $ fields = null ) { if ( $ id == null && $ name == null && $ domain == null ) { throw new \ RuntimeException ( 'You must specify a company ID, a universal name, or an email domain.' ) ; } $ token = $ this -> oauth -> getToken ( ) ; $ parameters = array ( 'oauth_token' => $ token [ 'key' ] , ) ; $ base = '/v1/companies' ; if ( $ id && $ name ) { $ base .= '::(' . $ id . ',universal-name=' . $ name . ')' ; } elseif ( $ id ) { $ base .= '/' . $ id ; } elseif ( $ name ) { $ base .= '/universal-name=' . $ name ; } $ data [ 'format' ] = 'json' ; if ( $ domain ) { $ data [ 'email-domain' ] = $ domain ; } if ( $ fields ) { $ base .= ':' . $ fields ; } $ path = $ this -> getOption ( 'api.url' ) . $ base ; $ response = $ this -> oauth -> oauthRequest ( $ path , 'GET' , $ parameters , $ data ) ; return json_decode ( $ response -> body ) ; } | Method to retrieve companies using a company ID a universal name or an email domain . |
35,148 | public function getSuggested ( $ fields = null , $ start = 0 , $ count = 0 ) { $ token = $ this -> oauth -> getToken ( ) ; $ parameters = array ( 'oauth_token' => $ token [ 'key' ] , ) ; $ base = '/v1/people/~/suggestions/to-follow/companies' ; $ data [ 'format' ] = 'json' ; if ( $ fields ) { $ base .= ':' . $ fields ; } if ( $ start > 0 ) { $ data [ 'start' ] = $ start ; } if ( $ count > 0 ) { $ data [ 'count' ] = $ count ; } $ path = $ this -> getOption ( 'api.url' ) . $ base ; $ response = $ this -> oauth -> oauthRequest ( $ path , 'GET' , $ parameters , $ data ) ; return json_decode ( $ response -> body ) ; } | Method to get a collection of suggested companies for the current user . |
35,149 | protected function parseHttpAcceptLanguages ( $ httpAcceptLanguages ) { $ locales = $ this -> split ( $ httpAcceptLanguages , ',' ) ; foreach ( $ locales as $ httpAcceptLanguage ) { $ this -> makeLocale ( $ httpAcceptLanguage ) ; } $ this -> sortLocales ( ) ; } | Parse all HTTP Accept Languages . |
35,150 | protected function makeLocale ( $ httpAcceptLanguage ) { $ parts = $ this -> split ( $ httpAcceptLanguage , ';' ) ; $ locale = $ parts [ 0 ] ; $ weight = $ parts [ 1 ] ?? null ; if ( empty ( $ locale ) ) { return ; } $ this -> locales [ ] = new Locale ( $ locale , $ this -> getLanguage ( $ locale ) , $ this -> getCountry ( $ locale ) , $ this -> getWeight ( $ weight ) ) ; } | Convert the given HTTP Accept Language to a Locale object . |
35,151 | protected function getWeight ( $ q ) { $ parts = $ this -> split ( $ q , '=' ) ; $ weight = $ parts [ 1 ] ?? 1.0 ; return ( float ) $ weight ; } | Parse the relative quality factor and return its value . |
35,152 | protected function sortLocales ( ) { usort ( $ this -> locales , function ( $ a , $ b ) { if ( $ a -> weight === $ b -> weight ) { return 0 ; } return ( $ a -> weight > $ b -> weight ) ? - 1 : 1 ; } ) ; } | Sort the array of locales in descending order of preference . |
35,153 | public function getShopownerParameter ( $ parameterName ) { if ( ! array_key_exists ( $ parameterName , $ this -> shopowner ) ) { throw new SalesConfigParameterNotFoundException ( ) ; } return $ this -> shopowner [ $ parameterName ] ; } | Returns the value of the given parameter from the shopowner config data . |
35,154 | public static function fromReflection ( ReflectionFunction $ reflectionFunction ) { $ name = self :: extractShortNameFromFullyQualifiedName ( $ reflectionFunction -> getName ( ) ) ; $ namespace = self :: extractNamespaceFromQualifiedName ( $ reflectionFunction -> getName ( ) ) ; $ function = new static ( $ name , trim ( $ reflectionFunction -> getBody ( ) ) ) ; $ function -> setNamespace ( $ namespace ) ; foreach ( $ reflectionFunction -> getParameters ( ) as $ parameter ) { $ function -> addParameter ( ParameterGenerator :: fromReflection ( $ parameter ) ) ; } if ( $ reflectionFunction -> getReflectionDocComment ( ) -> isEmpty ( ) !== true ) { $ function -> setDocumentation ( DocCommentGenerator :: fromReflection ( $ reflectionFunction -> getReflectionDocComment ( ) ) ) ; } return $ function ; } | Create a new function from reflection . |
35,155 | public function initialize ( $ subject , $ callback = null ) { $ class = is_string ( $ subject ) ? ltrim ( $ subject , '\\' ) : $ subject :: className ( ) ; if ( ! isset ( $ this -> _schema [ $ class ] ) ) { $ builder = new \ Pheasant \ SchemaBuilder ( $ this ) ; $ initializer = $ callback ? $ callback : $ class . '::initialize' ; $ this -> events ( ) -> trigger ( 'beforeInitialize' , $ builder ) ; call_user_func ( $ initializer , $ builder , $ this ) ; $ schema = $ builder -> build ( $ class ) ; $ this -> _schema [ $ class ] = $ schema ; $ this -> events ( ) -> trigger ( 'afterInitialize' , $ schema ) ; } return $ class ; } | Initializes a domain objects schema if it has not yet been initialized |
35,156 | public function mapperFor ( $ subject ) { $ class = $ this -> initialize ( $ subject ) ; if ( ! isset ( $ this -> _mappers [ $ class ] ) ) throw new Exception ( "No mapper registered for $class" ) ; return $ this -> _mappers [ $ class ] ; } | Looks up a mapper for either an object or a classname |
35,157 | public function finderFor ( $ subject ) { $ class = $ this -> initialize ( $ subject ) ; if ( ! isset ( $ this -> _finders [ $ class ] ) ) throw new Exception ( "No finder registered for $class" ) ; return $ this -> _finders [ $ class ] ; } | Looks up a finder for either an object or a classname |
35,158 | public function events ( ) { if ( ! isset ( $ this -> _events ) ) { $ this -> _events = new \ Pheasant \ Events ( ) ; } return $ this -> _events ; } | Gets the system - wide events registry |
35,159 | public static function transaction ( $ closure , $ execute = true ) { $ transaction = self :: instance ( ) -> connection ( ) -> transaction ( ) ; $ transaction -> callback ( $ closure ) ; if ( $ execute ) $ transaction -> execute ( ) ; return $ transaction ; } | Creates a transaction optionally executes |
35,160 | public static function loginUser ( $ login , $ password , $ authenticationMatch = false ) { try { $ syliusUser = self :: $ userProvider -> loadUserByUsername ( $ login ) ; } catch ( UsernameNotFoundException $ e ) { self :: loginFailed ( false , $ login ) ; return false ; } $ apiUser = $ syliusUser -> getAPIUser ( ) ; if ( ! $ apiUser instanceof User ) { self :: loginFailed ( false , $ login ) ; return false ; } $ encoder = self :: $ encoderFactory -> getEncoder ( $ syliusUser ) ; if ( ! $ encoder -> isPasswordValid ( $ syliusUser -> getPassword ( ) , $ password , $ syliusUser -> getSalt ( ) ) ) { self :: loginFailed ( $ apiUser -> getUserId ( ) , $ login ) ; return false ; } $ user = self :: fetch ( $ apiUser -> getUserId ( ) ) ; if ( ! $ user instanceof eZUser ) { self :: loginFailed ( $ apiUser -> getUserId ( ) , $ login ) ; return false ; } self :: loginSucceeded ( $ user ) ; return $ user ; } | Checks if there s an admin Sylius user with login entered by the user . If so it checks if entered password is correct and if that is the case it returns the legacy user . |
35,161 | public function addChildAsLast ( Node $ node ) { if ( null === $ this -> children ) { $ this -> children = array ( ) ; } $ this -> children [ ] = $ node ; } | Add a child to the end of child nodes list |
35,162 | public function getChildByIndex ( $ index ) { $ index = intval ( $ index ) ; return ( ( null !== $ this -> children ) && array_key_exists ( $ index , $ this -> children ) ) ? $ this -> children [ $ index ] : null ; } | Get child Node by Index |
35,163 | public function setProperty ( $ key , $ value ) { if ( null === $ this -> properties ) { $ this -> properties = array ( ) ; } $ key = ( string ) $ key ; $ value = ( string ) $ value ; $ this -> properties [ $ key ] = $ value ; if ( ( substr ( $ key , 0 , 5 ) == 'tree_' ) && $ this -> hasChildren ( ) ) { foreach ( $ this -> children as $ child ) { if ( ! $ child -> hasProperty ( $ key ) ) { $ child -> setProperty ( $ key , $ value ) ; } } } } | Set Node property |
35,164 | public function hasProperty ( $ key ) { return ( null !== $ this -> properties ) && ( array_key_exists ( ( string ) $ key , $ this -> properties ) || array_key_exists ( 'tree_' . $ key , $ this -> properties ) ) ; } | Get Node peroperty |
35,165 | public function getProperty ( $ key , $ default = false ) { if ( ! $ this -> hasProperty ( $ key ) ) { return $ default ; } if ( array_key_exists ( ( string ) $ key , $ this -> properties ) ) { $ value = $ this -> properties [ $ key ] ; } else { $ value = $ this -> properties [ 'tree_' . $ key ] ; } $ valueLow = strtolower ( $ value ) ; if ( $ valueLow == 'true' || $ valueLow == 'false' ) { return ( $ valueLow == 'true' ) ; } return $ value ; } | Get Node property |
35,166 | public function bind ( $ sql , array $ params = array ( ) ) { return $ this -> _bindInto ( '\?' , $ sql , $ params , function ( $ binder , $ param ) use ( $ sql ) { return $ binder -> sqlValue ( $ param ) ; } ) ; } | Interpolates quoted values in a string with ? in it . |
35,167 | public function quote ( $ string ) { if ( is_null ( $ string ) ) { return 'NULL' ; } else if ( is_bool ( $ string ) ) { return $ string === true ? 1 : "''" ; } else { return sprintf ( "'%s'" , $ string ) ; } } | Surrounds a string with quote marks null is returned as NULL bools converted to 1|empty string for compatibility |
35,168 | public function reduce ( $ array ) { $ tokens = array ( ) ; foreach ( $ array as $ a ) { $ tokens [ ] = $ this -> quote ( $ this -> escape ( $ a ) ) ; } return $ tokens ? '(' . implode ( ',' , $ tokens ) . ')' : '(null)' ; } | Reduces an array of values into a bracketed quoted comma delimited list |
35,169 | public function _bindInto ( $ pattern , $ sql , $ params , $ func ) { $ result = NULL ; $ regex = "/('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"|$pattern)/" ; foreach ( preg_split ( $ regex , $ sql , - 1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) as $ token ) { if ( $ token == '?' || ( $ token [ 0 ] != '"' && $ token [ 0 ] != "'" && preg_match ( "/$pattern/" , $ token ) ) ) { if ( ! count ( $ params ) ) throw new \ InvalidArgumentException ( "Not enough parameters to bind($sql)" ) ; $ result .= $ func ( $ this , array_shift ( $ params ) , $ token ) ; } else { $ result .= $ token ; } } if ( count ( $ params ) ) { $ exception = new \ InvalidArgumentException ( "Parameters left over in bind($sql)" ) ; $ exception -> leftOverParams = $ params ; throw $ exception ; } return $ result ; } | Bind parameters into a particular pattern skipping quoted strings which might have question marks in them . |
35,170 | public function mediator ( array $ parameters ) { $ caller = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS , 2 ) [ 1 ] [ 'function' ] ; if ( $ this -> shouldCache ( ) ) { return $ this -> mediator -> cache ( $ caller , $ parameters ) ; } return $ this -> mediator -> database ( $ caller , $ parameters ) ; } | Call an action on mediator . |
35,171 | public function criteria ( $ criteria = null ) { if ( is_null ( $ criteria ) ) { return $ this -> mediator -> criteria ( ) ; } if ( ! is_null ( $ criteria ) && ! is_a ( $ criteria , CriteriaInterface :: class ) ) { throw new InvalidCriteria ( ) ; } $ this -> mediator -> criteria ( ) -> addCriteria ( $ criteria ) ; return $ this ; } | Add criteria to repository query or return criteria service . |
35,172 | public function makeModel ( ) { if ( ! ( $ this -> model = $ this -> app -> make ( $ this -> takeModel ( ) ) ) instanceof Eloquent ) { throw new InvalidRepositoryModel ( get_class ( $ this -> model ) , Eloquent :: class ) ; } return $ this -> model ; } | Return instance of Eloquent model . |
35,173 | public function makeQuery ( ) { $ query = $ this -> makeModel ( ) -> query ( ) ; if ( $ this -> mediator -> hasCriteria ( ) ) { $ query = $ this -> mediator -> criteria ( ) -> executeOn ( $ this -> makeModel ( ) -> query ( ) ) ; } return empty ( $ this -> with ) ? $ query : $ query -> with ( $ this -> with ) ; } | Return instance of query builder for Eloquent model . |
35,174 | public function with ( $ relation ) { if ( func_num_args ( ) == 1 ) { $ this -> with = array_merge ( $ this -> with , is_array ( $ relation ) ? $ relation : [ $ relation ] ) ; } else { $ this -> with = array_merge ( $ this -> with , func_get_args ( ) ) ; } return $ this ; } | Adds relation to eager loads . |
35,175 | public function setTransformer ( $ transformer ) { if ( ! ( new \ ReflectionClass ( $ transformer ) ) -> implementsInterface ( TransformerInterface :: class ) ) { throw new InvalidTransformer ( ) ; } $ this -> transformer = $ transformer ; return $ this ; } | Sets transformer to current repository instance . |
35,176 | public function findWhere ( array $ wheres , array $ columns = [ '*' ] ) { return $ this -> mediator -> transform ( $ this -> mediator ( func_get_args ( ) ) ) -> first ( ) ; } | Find a model by its specified columns and values . |
35,177 | public function addConnection ( $ name , $ dsn ) { if ( isset ( $ this -> _connections [ $ name ] ) ) throw new \ Pheasant \ Exception ( "Connection $name already exists" ) ; $ this -> _connections [ $ name ] = $ dsn ; return $ this ; } | Adds a named connection with a string dsn |
35,178 | private function _buildConnection ( Dsn $ dsn ) { if ( isset ( $ this -> _drivers [ $ dsn -> scheme ] ) ) { $ driver = $ this -> _drivers [ $ dsn -> scheme ] ; return is_string ( $ driver ) ? new $ driver ( $ dsn ) : call_user_func ( $ driver , $ dsn ) ; } switch ( $ dsn -> scheme ) { case 'mysql' : case 'mysqli' : return new Mysqli \ Connection ( $ dsn ) ; } throw new \ Pheasant \ Exception ( "Unknown driver $driver" ) ; } | Builds a connection object for a given Dsn |
35,179 | public function transChoice ( ) { $ args = func_get_args ( ) ; $ args [ 0 ] = $ this -> transName ( $ args [ 0 ] ) ; return call_user_func_array ( [ $ this -> app [ 'translator' ] , 'transChoice' ] , $ args ) ; } | Translates the given message based on a count . |
35,180 | public function initialize ( ) { $ this -> _connection -> table ( self :: TABLE ) -> createIfNotExists ( array ( 'name' => new \ Pheasant \ Types \ StringType ( 255 , 'notnull primary' ) , 'id' => new \ Pheasant \ Types \ IntegerType ( null , 'notnull unsigned' ) , ) ) ; return $ this ; } | Creates the sequence table if it doesn t exist |
35,181 | public function next ( $ sequence ) { $ results = $ this -> _connection -> transaction ( array ( $ this , '_nextSequence' ) , strtoupper ( $ sequence ) ) -> execute ( ) ; return ( int ) $ results [ 0 ] ; } | Returns the next integer in the sequence |
35,182 | public function _nextSequence ( $ sequence ) { $ sequence = strtoupper ( $ sequence ) ; $ id = $ this -> _lockSequence ( $ sequence ) ; $ increment = $ this -> _connection -> execute ( "UPDATE sequences SET id=id+1 WHERE name=?" , $ sequence ) ; return $ id ; } | Called within a transaction gets the next sequence value |
35,183 | private function _lockSequence ( $ sequence ) { $ result = $ this -> _connection -> execute ( "SELECT id FROM sequences WHERE name=? FOR UPDATE" , $ sequence ) ; switch ( count ( $ result ) ) { case 0 : $ this -> _connection -> execute ( "INSERT INTO sequences VALUES (?,?)" , $ sequence , $ this -> _startId ) ; $ id = $ this -> _startId ; break ; case 1 : $ id = $ result [ 0 ] [ 'id' ] ; break ; default : throw new \ Pheasant \ Exception ( "Multiple rows exist for sequence '$sequence'" ) ; break ; } return $ id ; } | Locks the sequence creates it if needed and returns the current value |
35,184 | public function sendNotification ( NotificationInterface $ notification ) { $ uri = $ notification -> buildUri ( $ this -> endpoint , $ this -> hubPath ) . self :: API_VERSION ; $ token = $ this -> generateSasToken ( $ uri ) ; $ headers = array_merge ( [ 'Authorization: ' . $ token ] , $ notification -> getHeaders ( ) ) ; $ this -> request ( self :: METHOD_POST , $ uri , $ headers , $ notification -> getPayload ( ) ) ; } | Send a Notification . |
35,185 | public function updateRegistration ( RegistrationInterface $ registration ) { if ( ! $ registration -> getRegistrationId ( ) ) { throw new \ RuntimeException ( 'Registration ID is mandatory.' ) ; } $ uri = $ registration -> buildUri ( $ this -> endpoint , $ this -> hubPath ) . self :: API_VERSION ; $ token = $ this -> generateSasToken ( $ uri ) ; $ headers = array_merge ( [ 'Authorization: ' . $ token ] , $ registration -> getHeaders ( ) ) ; $ response = $ this -> request ( self :: METHOD_PUT , $ uri , $ headers , $ registration -> getPayload ( ) ) ; return $ registration -> scrapeResponse ( $ response ) ; } | Create or Update Registration . |
35,186 | public function deleteRegistration ( RegistrationInterface $ registration ) { if ( ! $ registration -> getRegistrationId ( ) || ! $ registration -> getETag ( ) ) { throw new \ RuntimeException ( 'Registration ID and ETag are mandatory.' ) ; } $ uri = $ registration -> buildUri ( $ this -> endpoint , $ this -> hubPath ) . self :: API_VERSION ; $ token = $ this -> generateSasToken ( $ uri ) ; $ headers = array_merge ( [ 'Authorization: ' . $ token ] , $ registration -> getHeaders ( ) ) ; $ this -> request ( self :: METHOD_DELETE , $ uri , $ headers ) ; } | Delete Registration . |
35,187 | public function readRegistration ( RegistrationInterface $ registration ) { if ( ! $ registration -> getRegistrationId ( ) ) { throw new \ RuntimeException ( 'Registration ID is mandatory.' ) ; } $ uri = $ registration -> buildUri ( $ this -> endpoint , $ this -> hubPath ) . self :: API_VERSION ; $ token = $ this -> generateSasToken ( $ uri ) ; $ headers = array_merge ( [ 'Authorization: ' . $ token ] , $ registration -> getHeaders ( ) ) ; $ response = $ this -> request ( self :: METHOD_GET , $ uri , $ headers ) ; return $ registration -> scrapeResponse ( $ response ) ; } | Read Registration . |
35,188 | public function readAllRegistrationsOfAChannel ( RegistrationInterface $ registration ) { if ( ! $ registration -> getToken ( ) ) { throw new \ RuntimeException ( 'Token is mandatory.' ) ; } $ uri = $ registration -> buildUri ( $ this -> endpoint , $ this -> hubPath ) . self :: API_VERSION . '&$filter=' . urlencode ( $ registration -> getTokenTag ( ) . ' eq \'' . $ registration -> getToken ( ) . '\'' ) ; $ token = $ this -> generateSasToken ( $ uri ) ; $ headers = array_merge ( [ 'Authorization: ' . $ token ] , $ registration -> getHeaders ( ) ) ; $ response = $ this -> request ( self :: METHOD_GET , $ uri , $ headers ) ; $ dom = new \ DOMDocument ( ) ; $ dom -> loadXML ( $ response ) ; $ registrations = [ ] ; foreach ( $ dom -> getElementsByTagName ( 'entry' ) as $ entry ) { $ registrations [ ] = $ registration -> scrapeResponse ( $ dom -> saveXML ( $ entry ) ) ; } return $ registrations ; } | Read All Registrations of a Channel . |
35,189 | public function createRegistrationId ( ) { $ registration = new GcmRegistration ( ) ; $ uri = $ this -> endpoint . $ this -> hubPath . '/registrationIDs/' ; $ token = $ this -> generateSasToken ( $ uri ) ; $ headers = array_merge ( [ 'Authorization: ' . $ token ] , $ registration -> getHeaders ( ) ) ; $ headers = array_merge ( [ 'Content-length: 0' ] , $ headers ) ; $ response = $ this -> request ( self :: METHOD_POST , $ uri . self :: API_VERSION , $ headers , null , true ) ; preg_match ( '#' . $ uri . '([^?]+)' . preg_quote ( self :: API_VERSION ) . '#' , $ response , $ matches ) ; return $ matches [ 1 ] ; } | Create Registration ID . |
35,190 | protected function request ( $ method , $ uri , $ headers , $ payload = null , $ responseHeader = false ) { $ ch = curl_init ( $ uri ) ; $ options = [ CURLOPT_RETURNTRANSFER => true , CURLOPT_SSL_VERIFYPEER => false , CURLOPT_HEADER => $ responseHeader , CURLOPT_HTTPHEADER => $ headers , ] ; $ options [ CURLOPT_CUSTOMREQUEST ] = $ method ; if ( ! is_null ( $ payload ) ) { $ options [ CURLOPT_POSTFIELDS ] = $ payload ; } curl_setopt_array ( $ ch , $ options ) ; $ response = curl_exec ( $ ch ) ; if ( false === $ response ) { throw new \ RuntimeException ( curl_error ( $ ch ) ) ; } $ info = curl_getinfo ( $ ch ) ; if ( 200 != $ info [ 'http_code' ] && 201 != $ info [ 'http_code' ] ) { throw new \ RuntimeException ( 'Error sending request: ' . $ info [ 'http_code' ] . ' msg: ' . $ response ) ; } return $ response ; } | Send the request to API . |
35,191 | private function parseConnectionString ( $ connectionString ) { $ parts = explode ( ';' , $ connectionString ) ; if ( 3 != count ( $ parts ) ) { throw new \ RuntimeException ( 'Error parsing connection string: ' . $ connectionString ) ; } foreach ( $ parts as $ part ) { if ( 0 === strpos ( $ part , 'Endpoint' ) ) { $ this -> endpoint = 'https' . substr ( $ part , 11 ) ; } elseif ( 0 === strpos ( $ part , 'SharedAccessKeyName' ) ) { $ this -> sasKeyName = substr ( $ part , 20 ) ; } elseif ( 0 === strpos ( $ part , 'SharedAccessKey' ) ) { $ this -> sasKeyValue = substr ( $ part , 16 ) ; } } if ( ! $ this -> endpoint || ! $ this -> sasKeyName || ! $ this -> sasKeyValue ) { throw new \ RuntimeException ( 'Invalid connection string: ' . $ connectionString ) ; } } | Parses the connection string . |
35,192 | private function generateSasToken ( $ uri ) { $ targetUri = strtolower ( rawurlencode ( strtolower ( $ uri ) ) ) ; $ expires = time ( ) ; $ expiresInMins = 60 ; $ expires = $ expires + $ expiresInMins * 60 ; $ toSign = $ targetUri . "\n" . $ expires ; $ signature = rawurlencode ( base64_encode ( hash_hmac ( 'sha256' , $ toSign , $ this -> sasKeyValue , true ) ) ) ; $ token = 'SharedAccessSignature sr=' . $ targetUri . '&sig=' . $ signature . '&se=' . $ expires . '&skn=' . $ this -> sasKeyName ; return $ token ; } | Generates the SAS token . |
35,193 | private function fillArea ( Area $ area , $ path ) { $ finder = new Finder ( $ path ) ; foreach ( SortorderParser :: parse ( $ finder ) as $ subPath ) { $ contentFullPath = $ path . DIRECTORY_SEPARATOR . $ subPath ; if ( file_exists ( $ contentFullPath ) ) { $ type = substr ( $ subPath , strrpos ( $ subPath , '.' ) + 1 ) ; $ area -> addContentAsLast ( new Content ( $ type , substr ( $ contentFullPath , strlen ( $ this -> contentPath ) ) ) ) ; } else { throw new PageException ( "Unable to find content at [$contentFullPath]" ) ; } } } | Fill area content from files |
35,194 | private function scanAreas ( $ dirPath ) { $ dirPath = realpath ( $ dirPath ) ; if ( strcmp ( $ this -> contentPath , $ dirPath ) > 0 ) { return ; } if ( is_dir ( $ dirPath ) && ( ( $ dir = @ opendir ( $ dirPath ) ) !== false ) ) { while ( ( $ subDirName = readdir ( $ dir ) ) !== false ) { if ( ( ( substr ( $ subDirName , 0 , 1 ) == '.' ) || ( substr ( $ subDirName , 0 , 1 ) == '_' ) ) && $ subDirName != '.' && $ subDirName != '..' && is_dir ( $ dirPath . DIRECTORY_SEPARATOR . $ subDirName ) ) { $ areaName = $ subDirName ; if ( realpath ( $ this -> contentPath . $ this -> getNode ( ) -> getUri ( ) ) == $ dirPath ) { $ areaName = ( substr ( $ areaName , 1 , 5 ) == 'tree_' ) ? substr ( $ areaName , 6 ) : substr ( $ areaName , 1 ) ; $ area = new Area ( $ areaName , false ) ; $ this -> areas [ $ areaName ] = $ area ; $ this -> fillArea ( $ area , $ dirPath . DIRECTORY_SEPARATOR . $ subDirName ) ; } else { if ( substr ( $ areaName , 1 , 5 ) == 'tree_' ) { $ areaName = substr ( $ areaName , 6 ) ; if ( ! $ this -> hasArea ( $ areaName ) ) { $ area = new Area ( $ areaName , true ) ; $ this -> areas [ $ areaName ] = $ area ; $ this -> fillArea ( $ area , $ dirPath . DIRECTORY_SEPARATOR . $ subDirName ) ; } } } } } closedir ( $ dir ) ; } else { throw new PageException ( "Unable to read path" ) ; } $ this -> scanAreas ( $ dirPath . '/..' ) ; } | Read area definitions and content from the disk |
35,195 | public function getArea ( $ name ) { if ( null === $ this -> areas ) { $ this -> areas = array ( ) ; $ this -> scanAreas ( $ this -> contentPath . $ this -> getNode ( ) -> getUri ( ) ) ; } return array_key_exists ( $ name , $ this -> areas ) ? $ this -> areas [ $ name ] : null ; } | Return Area object if it exists |
35,196 | private function readNode ( Finder $ finder ) { $ uri = str_replace ( $ this -> contentPath , '' , $ finder -> getPath ( ) ) ; $ uri = ! $ uri ? '/' : $ uri ; if ( false !== $ finder -> getPropertiesPath ( ) ) { $ properties = PropertiesParser :: parse ( $ finder ) ; $ node = new Node ( $ properties [ 'name' ] , $ uri ) ; foreach ( $ properties [ 'properties' ] as $ key => $ value ) { $ node -> setProperty ( $ key , $ value ) ; } $ parentDir = realpath ( dirname ( $ finder -> getPropertiesPath ( ) ) ) ; while ( strcmp ( $ this -> contentPath , $ parentDir ) <= 0 ) { $ parentFinder = new Finder ( $ parentDir ) ; if ( false !== $ parentFinder -> getPropertiesPath ( ) ) { $ properties = PropertiesParser :: parse ( $ parentFinder ) ; foreach ( $ properties [ 'properties' ] as $ key => $ value ) { if ( ( substr ( $ key , 0 , 5 ) == 'tree_' ) && ! $ node -> hasProperty ( $ key ) ) { $ node -> setProperty ( $ key , $ value ) ; } } } else { throw new SitemapException ( sprintf ( 'Unable to read properties [%s].' , $ parentFinder -> getPath ( ) ) ) ; } $ parentDir = realpath ( $ parentDir . '/..' ) ; } return $ node ; } throw new SitemapException ( sprintf ( 'Unable to read node for request [%s].' , $ uri ) ) ; } | Recursively reads Node properties . Node is not a structure |
35,197 | public function setNodeByUri ( $ uri ) { $ this -> areas = null ; $ finder = new Finder ( $ this -> contentPath . $ uri ) ; $ this -> node = $ this -> readNode ( $ finder ) ; } | Reset node that is set by RequestFilter . Hard |
35,198 | public function full_file_root_path ( ) { $ subDirs = implode ( '/' , $ this -> subDirs ) ; if ( $ subDirs ) { $ subDirs .= '/' ; } return $ this -> baseDir . '/' . $ subDirs . $ this -> fileRoot ; } | Full path except file extension |
35,199 | public function relative_file_root_path ( ) { $ subDirs = implode ( '/' , $ this -> subDirs ) ; if ( $ subDirs ) { $ subDirs .= '/' ; } return $ subDirs . $ this -> fileRoot ; } | Sub dirs + file root |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.