idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
14,200 | public function orWhereColumn ( ... $ arguments ) : self { $ this -> where [ ] = $ this -> whereArgumentsToCriterion ( $ arguments , 'OR' , true ) ; return $ this ; } | The same as whereColumn but the result criterion is appended to the where group with the OR append rule . |
14,201 | public function whereExists ( $ subQuery , bool $ not = false , string $ appendRule = 'AND' ) : self { $ subQuery = $ this -> checkSubQueryValue ( 'Argument $subQuery' , $ subQuery ) ; $ this -> where [ ] = new ExistsCriterion ( $ subQuery , $ not , $ appendRule ) ; return $ this ; } | Adds a EXISTS criterion to the WHERE section . |
14,202 | protected function whereArgumentsToCriterion ( array $ arguments , string $ appendRule = 'AND' , bool $ valueIsColumn = false ) : Criterion { switch ( $ argumentsCount = count ( $ arguments ) ) { case 0 : return $ this -> handleException ( new InvalidArgumentException ( 'Too few arguments' ) ) ; case 1 : $ argument = $... | Converts where method arguments to a criterion object |
14,203 | public function match ( Subject $ subject , string $ verb ) : bool { return $ this -> subject -> getType ( ) == $ subject -> getType ( ) && $ this -> subject -> getId ( ) === $ subject -> getId ( ) && ( $ this -> verbs === null || in_array ( $ verb , $ this -> verbs , true ) ) ; } | Gets whether this Rule matches the Subject and verb provided . |
14,204 | public static function allow ( Subject $ subject , array $ verbs = null ) : Rule { return new self ( $ subject , true , $ verbs ) ; } | Creates an allowing Rule . |
14,205 | public static function deny ( Subject $ subject , array $ verbs = null ) : Rule { return new self ( $ subject , false , $ verbs ) ; } | Creates an denying Rule . |
14,206 | public function cmdGetPage ( ) { $ result = $ this -> getListPage ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTablePage ( $ result ) ; $ this -> output ( ) ; } | Callback for page - get command |
14,207 | public function cmdDeletePage ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; $ blog = $ this -> getParam ( 'blog' ) ; if ( empty ( $ id ) && empty ( $ all ) && empty ( $ blog ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( isset ( $ id ) && ( empty ( $ id )... | Callback for page - delete command |
14,208 | public function cmdUpdatePage ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ this -> ... | Callback for page - update command |
14,209 | protected function addPage ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> page -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } } | Add a new page |
14,210 | protected function submitAddPage ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'page' ) ; $ this -> addPage ( ) ; } | Add a new page at once |
14,211 | protected function wizardAddPage ( ) { $ this -> validatePrompt ( 'title' , $ this -> text ( 'Title' ) , 'page' ) ; $ this -> validatePrompt ( 'description' , $ this -> text ( 'Description' ) , 'page' ) ; $ this -> validatePrompt ( 'store_id' , $ this -> text ( 'Store ID' ) , 'page' ) ; $ this -> validatePrompt ( 'user... | Add a new page step by step |
14,212 | public static function make ( $ total = 0 , $ message = '' , $ value = 0 , $ startTime = null , $ current = null ) { $ now = time ( ) ; return new self ( $ current ? : $ now , $ startTime ? : $ now , $ value , $ total , $ message ) ; } | Helper function to create a new object |
14,213 | public function registerClass ( string $ class , string $ name ) { if ( isset ( $ this -> classes [ $ name ] ) ) throw new Exception ( "Cannot register the same name twice" ) ; if ( ! is_a ( $ class , ACLModel :: class , true ) ) throw new TypeError ( "Class must be subclass of ACLModel" ) ; $ this -> classes [ $ name ... | Register the name of the object class to be used in ACL entity naming . |
14,214 | public function loadByACLID ( $ id ) { $ parts = explode ( "#" , $ id ) ; if ( count ( $ parts ) !== 2 ) throw new Exception ( "Invalid DAO ID: {$id}" ) ; if ( ! isset ( $ this -> classes [ $ parts [ 0 ] ] ) ) throw new Exception ( "Invalid DAO type: {$parts[0]}" ) ; $ classname = $ this -> classes [ $ parts [ 0 ] ] ; ... | This method will load a new instance to be used in ACL inheritance |
14,215 | public function getInstance ( string $ class , $ element_id ) { if ( ! is_a ( $ class , Hierarchy :: class , true ) ) throw new TypeError ( "Not a subclass of Hierarchy: $class" ) ; if ( is_object ( $ element_id ) && get_class ( $ element_id ) === $ class ) return $ element_id ; if ( ! is_scalar ( $ element_id ) ) thro... | Get an hierarchy element by specifying its ID |
14,216 | public function getRoot ( string $ class ) { if ( ! is_a ( $ class , Hierarchy :: class , true ) ) throw new TypeError ( "Not a subclass of Hierarchy: $class" ) ; $ root = $ class :: getRootName ( ) ; return $ this -> getInstance ( $ class , $ root ) ; } | Return the root element for a certain hierarchy |
14,217 | public function createEntity ( string $ entity_id , array $ parents ) { $ entity = new Entity ( $ this , $ entity_id , $ parents ) ; return $ entity ; } | Create a new entity and store it . |
14,218 | public function setInstance ( Hierarchy $ element ) { $ class = get_class ( $ element ) ; $ this -> hierarchy [ $ class ] [ $ element -> getID ( ) ] = $ element ; return $ this ; } | Set the instance of a specific ID . |
14,219 | public function load ( $ file , array $ data = array ( ) ) { $ this -> queries = array ( ) ; $ this -> data = $ data ; include $ file ; return $ this ; } | Load script file |
14,220 | public function execute ( ) { if ( method_exists ( $ this , 'setUp' ) ) { call_user_func_array ( [ $ this , 'setUp' ] , [ $ this -> request ] ) ; } call_user_func_array ( [ $ this , $ this -> action ] , [ $ this -> request ] ) ; } | Execute la bonne fonction enfante en fonction de l action |
14,221 | private function getBy ( $ search , $ column ) { $ search = mb_strtolower ( $ search , mb_detect_encoding ( $ search ) ) ; $ this -> procBuilder -> setArguments ( [ '-e' , "\t$search\t" ] ) ; $ process = $ this -> procBuilder -> getProcess ( ) ; $ process -> run ( ) ; $ csv = Csv \ Reader :: createFromString ( $ proces... | Get inflections by searching in a specific column . |
14,222 | public function finalize ( ) { $ gen = new UrlGenerator ( ) ; if ( ! empty ( $ this -> redirect ) ) { $ gen -> redirect ( $ this -> redirect ) ; } } | Finalize groups that implement the Groupable trait . |
14,223 | public static function createSlug ( $ string ) { $ string = self :: remove_accents ( $ string ) ; $ string = strtolower ( $ string ) ; $ slug = preg_replace ( '/[^A-Za-z0-9-]+/' , '-' , $ string ) ; while ( strpos ( '--' , $ slug ) ) { $ slug = str_replace ( '--' , '-' , $ slug ) ; } $ slug = trim ( $ slug , '-' ) ; re... | Creates slug from any string |
14,224 | public function rules ( ) { $ attributes = [ 'title' => 'required' , 'text' => 'required' , ] ; $ rules = $ this -> buildLocalizedRules ( $ attributes ) ; return array_merge ( $ rules , [ 'id' => 'exists:site_pages,id' , 'slug' => 'required|alpha_dash|unique:site_pages,slug,' . $ this -> route ( 'sites' ) , 'published_... | validation that has to pass . |
14,225 | protected function buildLocalizedRules ( $ attributes ) { $ rules = [ ] ; $ locales = config ( 'app.locales' ) ; foreach ( $ locales as $ locale => $ name ) { foreach ( $ attributes as $ attribute => $ rule ) { $ rules [ $ attribute . '_' . $ locale ] = $ rule ; } } return $ rules ; } | builds localized suffixed rules for validation . |
14,226 | public function getPrimaryKeyValue ( ) { $ primaryKey = $ this -> getPrimaryKey ( ) ; if ( isset ( $ this -> $ primaryKey ) ) { return $ this -> $ primaryKey ; } else { return null ; } } | Returns the value of the primary key |
14,227 | public function toAssoc ( ) { $ params = [ ] ; foreach ( Extract :: getObjectVars ( $ this ) as $ key => $ value ) { if ( ! $ value instanceof Relation ) { $ params [ $ key ] = $ value ; } } if ( $ this -> getPrimaryKeyValue ( ) === null ) { unset ( $ params [ $ this -> getPrimaryKey ( ) ] ) ; } return $ params ; } | Returns an associative array from this object excluding private variables and Relation objects |
14,228 | public function hydrate ( $ data , $ removePrimaryKey = false ) { foreach ( $ data as $ key => $ value ) { if ( property_exists ( $ this , $ key ) ) { $ this -> $ key = $ value ; } else { $ this -> extra [ $ key ] = $ value ; } } if ( $ removePrimaryKey ) { $ key = $ this -> getPrimaryKey ( ) ; $ this -> $ key = null ;... | Sets the properties of this object using an associative array where key is the property name and value is the property value . |
14,229 | public function limit ( $ limit , $ offset = null ) { $ this -> queryBuilder -> setLimit ( $ limit , $ offset ) ; return $ this ; } | Limit the amount of maximum rows returned |
14,230 | public function loadRules ( string $ entity_id ) { $ records = ACLRule :: get ( [ "entity_id" => $ entity_id ] ) ; $ rules = array ( ) ; foreach ( $ records as $ record ) { $ rule = new Rule ( $ record -> entity_id , $ record -> role_id , $ record -> action , $ record -> policy ) ; $ rule -> setRecord ( $ record ) ; $ ... | Loads the rules for the specified entity from the database . |
14,231 | public function setTextFont ( $ path ) { if ( ! is_file ( $ path ) || ! is_readable ( $ path ) ) { throw new \ InvalidArgumentException ( 'Unable to load font file at ' . $ path ) ; } $ this -> textFontPath = realpath ( $ path ) ; return $ this ; } | Sets the path to the font file used for rendering text overlays onto the image . |
14,232 | public function addDictionary ( string $ locale , $ callbackOrArray ) : \ BearFramework \ Localization { if ( ! isset ( $ this -> dictionaries [ $ locale ] ) ) { $ this -> dictionaries [ $ locale ] = [ ] ; } $ this -> dictionaries [ $ locale ] [ ] = $ callbackOrArray ; return $ this ; } | Adds a new dictionary . |
14,233 | public function getText ( string $ id ) : ? string { $ getText = function ( string $ id , string $ locale ) { if ( isset ( $ this -> defaultLocales [ $ locale ] ) && $ this -> defaultLocales [ $ locale ] === 0 ) { $ app = App :: get ( ) ; $ context = $ app -> contexts -> get ( __FILE__ ) ; $ this -> defaultLocales [ $ ... | Returns a text from the dictionary for the current locale . |
14,234 | protected function getNewConnection ( $ connections ) { $ connection = $ this -> ApplicationContext -> object ( $ this -> DatabaseServiceName ) ; $ connection -> setConnectionInfo ( $ connections ) ; return $ connection ; } | Gets a new connection using the connection info given |
14,235 | public function isMatching ( $ url ) { if ( $ this -> getRegex ( ) === null ) { return true ; } if ( preg_match ( $ this -> getRegex ( ) , $ url ) ) { return true ; } return false ; } | Check if route configuration matches url |
14,236 | public function extractPathInfo ( $ pathInfo ) { if ( $ this -> getRegex ( ) === null ) { return $ pathInfo ; } preg_match ( $ this -> getRegex ( ) , $ pathInfo , $ matches ) ; if ( isset ( $ matches [ 1 ] ) ) { return $ matches [ 1 ] ; } else { return "/" ; } } | Extract page pathinfo Call isMatching before to be sure regex matches |
14,237 | public function extractId ( $ routeName ) { if ( ! $ this -> supports ( $ routeName ) ) { return null ; } return ( int ) str_replace ( $ this -> getPrefix ( ) , '' , $ routeName ) ; } | Extract a page id from the route name |
14,238 | public function buildPath ( $ pathInfo ) { if ( null === $ this -> getPath ( ) ) { return $ pathInfo ; } return sprintf ( $ this -> getPath ( ) , rtrim ( $ pathInfo , '/' ) ) ; } | Build a path |
14,239 | public function toArray ( ) { $ keys = $ this -> redis -> hKeys ( $ this -> key ) ; $ result = array ( ) ; foreach ( $ keys as $ key ) { $ result [ $ key ] = $ this -> offsetGet ( $ key ) ; } return $ result ; } | Converts the hashset to an php - array |
14,240 | public function getMaxAge ( ) { if ( $ this -> headers -> hasCacheControlDirective ( 's-maxage' ) ) { return ( int ) $ this -> headers -> getCacheControlDirective ( 's-maxage' ) ; } if ( $ this -> headers -> hasCacheControlDirective ( 'max-age' ) ) { return ( int ) $ this -> headers -> getCacheControlDirective ( 'max-a... | Returns the number of seconds after the time specified in the response s Date header when the response should no longer be considered fresh . First it checks for a s - maxage directive then a max - age directive and then it falls back on an expires header . It returns null when no maximum age can be established . |
14,241 | public function setNotModified ( ) { $ this -> setStatusCode ( self :: HTTP_NOT_MODIFIED ) ; $ this -> setContent ( NULL ) ; foreach ( [ 'Allow' , 'Content-Encoding' , 'Content-Language' , 'Content-Length' , 'Content-MD5' , 'Content-Type' , 'Last-Modified' ] as $ header ) { $ this -> headers -> remove ( $ header ) ; } ... | Modifies the response so that it conforms to the rules defined for a 304 status code . This sets the status removes the body and discards any headers that MUST NOT be included in 304 responses . |
14,242 | protected function ensureIEOverSSLCompatibility ( Request $ request ) { if ( FALSE !== stripos ( $ this -> headers -> get ( 'Content-Disposition' ) , 'attachment' ) && preg_match ( '/MSIE (.*?);/i' , $ request -> server -> get ( 'HTTP_USER_AGENT' ) , $ match ) == 1 && TRUE === $ request -> isSecure ( ) ) { if ( intval ... | Check if we need to remove Cache - Control for ssl encrypted downloads when using IE < 9 |
14,243 | public function getValue ( $ field , $ default = null ) { if ( array_key_exists ( $ field , $ this -> defaults ) ) { switch ( $ this -> defaults [ $ field ] [ 'type' ] ) { case self :: TYPE_INT : return ( int ) $ this -> values [ $ field ] ; case self :: TYPE_FLOAT : $ f = sprintf ( '%05.3f' , $ this -> values [ $ fiel... | Get Label Format field from associative array . |
14,244 | public function isMetric ( $ field ) { if ( array_key_exists ( $ field , $ this -> defaults ) ) { return ( isset ( $ this -> defaults [ $ field ] [ 'metric' ] ) ) ? $ this -> defaults [ $ field ] [ 'metric' ] : false ; } return false ; } | Check if field is metric |
14,245 | public function init ( ) { $ host = getenv ( 'PDO_HOST' ) ; if ( $ host ) { $ this -> setHost ( trim ( $ host ) ) ; } $ database = getenv ( 'PDO_DATABASE' ) ; if ( $ database ) { $ this -> setDatabase ( trim ( $ database ) ) ; } $ user = getenv ( 'PDO_USER' ) ; if ( $ user ) { $ this -> setUser ( $ user ) ; } $ passwor... | Main init method |
14,246 | public static function getInject ( $ type = null ) { if ( $ type === null ) return static :: $ inject ; elseif ( isset ( static :: $ inject [ $ type ] ) ) return static :: $ inject [ $ type ] ; return array ( ) ; } | Fetches classes to inject from the config |
14,247 | protected static function initDB ( ) { $ dbConfig = static :: getConfig ( 'db' , static :: getServer ( ) ) ; static :: $ db = new Connection ( $ dbConfig [ 'dsn' ] , $ dbConfig [ 'user' ] , $ dbConfig [ 'password' ] , $ dbConfig [ 'options' ] ) ; static :: $ db -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXC... | Creates a database connection using \ DBScribe \ Connection |
14,248 | public static function getUrls ( ) { if ( static :: $ urls !== null ) return static :: $ urls ; $ uri = $ _SERVER [ 'REQUEST_URI' ] ; static :: $ isVirtual = true ; if ( substr ( $ uri , 0 , strlen ( $ _SERVER [ 'SCRIPT_NAME' ] ) ) === $ _SERVER [ 'SCRIPT_NAME' ] ) { $ uri = str_replace ( '/index.php' , '' , $ uri ) ; ... | Fetches the urls from the server request uri |
14,249 | protected static function checkAlias ( $ module ) { if ( array_key_exists ( $ module , static :: getConfig ( 'modules' ) ) ) return $ module ; foreach ( static :: getConfig ( 'modules' ) as $ cModule => $ moduleOptions ) { if ( ! array_key_exists ( 'alias' , $ moduleOptions ) ) continue ; if ( $ moduleOptions [ 'alias'... | Checks if the module is an alias and returns the ModuleName |
14,250 | public static function getModuleAlias ( $ module ) { if ( NULL !== $ alias = static :: getConfig ( 'modules' , $ module , 'alias' , false ) ) { return $ alias ; } return Util :: camelToHyphen ( $ module ) ; } | Fetches the alias for the given module |
14,251 | public static function getDefaultModule ( $ getAlias = false ) { if ( ! $ module = static :: getConfig ( 'defaults' , 'module' , false ) ) { $ modules = static :: getConfig ( 'modules' ) ; $ moduleNames = array_keys ( $ modules ) ; $ module = $ moduleNames [ 0 ] ; } return $ getAlias ? static :: getModuleAlias ( $ modu... | Fetches the default module from the config |
14,252 | public static function getDefaultController ( $ module = null , $ exception = false ) { $ module = ( $ module === null ) ? static :: getDefaultModule ( ) : $ module ; return static :: getConfig ( 'modules' , $ module , 'defaults' , 'controller' , $ exception ) ; } | Fetches the default controller from the config |
14,253 | public static function getDefaultAction ( $ module = null , $ exception = false ) { $ module = ( $ module === null ) ? static :: getDefaultModule ( ) : $ module ; return static :: getConfig ( 'modules' , $ module , 'defaults' , 'action' , $ exception ) ; } | Fetches the default action from the config |
14,254 | protected static function getControllerClass ( $ live = true ) { $ class = static :: getModule ( ) . '\Controllers\\' . static :: getController ( ) . 'Controller' ; if ( ! class_exists ( $ class ) ) ControllerException :: notFound ( $ class ) ; if ( ! in_array ( 'DScribe\Core\AController' , class_parents ( $ class ) ) ... | Creates an instance of the current controller class |
14,255 | protected static function authenticate ( $ controller , $ action , $ params ) { $ auth = new Authenticate ( static :: $ userId , $ controller , $ action ) ; if ( ! $ auth -> execute ( ) ) { $ controller -> accessDenied ( $ action , $ params ) ; exit ; } } | Authenticates the current user against the controller and action |
14,256 | public static function resetUserIdentity ( AUser $ user = NULL , $ duration = null ) { static :: $ userId = new UserIdentity ( $ user , $ duration ) ; if ( ! $ user ) Session :: reset ( ) ; static :: saveSession ( ) ; } | Resets the user to guest |
14,257 | protected function createLoginAttempt ( array $ data , array $ headers , array $ query ) { if ( empty ( $ data [ 'grant_type' ] ) ) { throw new \ InvalidArgumentException ( 'Any grant_type given.' ) ; } $ grantType = $ data [ 'grant_type' ] ; if ( ! $ this -> grantExtensions -> containsKey ( $ grantType ) ) { throw new... | Validate given request parameters and build a LoginAttempt object with it . |
14,258 | protected function loadApplication ( LoginAttempt $ loginAttempt ) { if ( ! $ application = $ this -> applicationLoader -> retrieveByApiKeyAndSecret ( $ loginAttempt -> getData ( 'client_api_key' ) , $ loginAttempt -> getData ( 'client_secret' ) ) ) { throw new InvalidGrantException ( $ loginAttempt , 'Any application ... | Loads application for given login attempt . |
14,259 | protected function loadAccount ( ApplicationInterface $ application , LoginAttempt $ loginAttempt ) { return $ this -> grantExtensions -> get ( $ loginAttempt -> getData ( 'grant_type' ) ) -> grant ( $ application , $ loginAttempt ) ; } | Runs grant extension to load accounts . |
14,260 | public function grant ( array $ data , array $ headers = array ( ) , array $ query = array ( ) ) { $ loginAttempt = $ this -> createLoginAttempt ( $ data , $ headers , $ query ) ; $ account = $ this -> loadAccount ( $ application = $ this -> loadApplication ( $ loginAttempt ) , $ loginAttempt ) ; $ this -> eventDispatc... | Grant given credentials or throws an exception if invalid credentials for application or account . |
14,261 | public static function start ( ) { if ( self :: $ _page ) { return null ; } self :: $ _page = new Html \ Document ( ) ; self :: $ _zones [ 'head' ] = self :: $ _page -> head ( ) ; self :: $ _zones [ 'body' ] = self :: $ _page -> body ( ) ; ob_start ( ) ; return self :: $ _page ; } | Initialize page . |
14,262 | public static function createZone ( $ zoneName , $ tag = 'div' ) { if ( self :: $ _page && ! isset ( self :: $ _zones [ $ zoneName ] ) ) { $ element = new Html \ Element ( $ tag ) ; self :: $ _zones [ $ zoneName ] = $ element ; self :: append ( self :: $ _outputZone , $ element ) ; return $ element ; } return null ; } | Create a new page zone . |
14,263 | public static function getZone ( $ zoneName = null ) { if ( $ zoneName === null ) { $ zoneName = self :: $ _outputZone ; } return ( isset ( self :: $ _zones [ $ zoneName ] ) ? self :: $ _zones [ $ zoneName ] : null ) ; } | Get zone element . |
14,264 | public static function append ( $ zoneName , ... $ data ) { if ( isset ( self :: $ _zones [ $ zoneName ] ) ) { self :: flushBuffer ( ) ; call_user_func_array ( array ( self :: $ _zones [ $ zoneName ] , 'append' ) , $ data ) ; return true ; } return false ; } | Append data to to zone . |
14,265 | public static function flushBuffer ( ) { if ( self :: $ _page && ob_get_length ( ) ) { self :: $ _zones [ self :: $ _outputZone ] -> append ( ob_get_clean ( ) ) ; ob_start ( ) ; return true ; } return false ; } | Flushes the output buffer to the current zone element . |
14,266 | public static function metaTag ( $ name , $ content ) { if ( self :: $ _page ) { self :: $ _page -> metaTag ( $ name , $ content ) ; } } | Set meta tag . |
14,267 | public static function end ( ) { if ( ! self :: $ _page || ErrorHandling :: lastError ( ) ) { return ; } self :: $ _zones [ self :: $ _outputZone ] -> append ( ob_get_clean ( ) ) ; self :: $ _page -> output ( ) ; self :: $ _page = null ; self :: $ _zones = array ( ) ; self :: $ _zoneStack = array ( ) ; self :: $ _outpu... | Finalize and output page . |
14,268 | public static function getType ( $ type ) { if ( ! isset ( self :: $ typesMap [ $ type ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid type specified "%s".' , $ type ) ) ; } if ( ! isset ( self :: $ typeObjects [ $ type ] ) ) { $ className = self :: $ typesMap [ $ type ] ; self :: $ typeObjects [ $ ty... | Get a Type instance . |
14,269 | public static function discountIsValid ( $ code ) { $ discount = Discount_Shortcuts_GetDiscountByCodeOrNull ( $ code ) ; if ( $ discount == null ) return false ; $ engine = Discount_Shortcuts_GetEngineOrNull ( $ discount -> get_type ( ) ) ; if ( $ engine == null ) return false ; return $ engine -> isValid ( $ discount ... | Checks if discount with given code is valid . |
14,270 | public static function getPrice ( $ originPrice , $ discountCode , $ request ) { $ discount = Discount_Shortcuts_GetDiscountByCodeOr404 ( $ discountCode ) ; $ engine = $ discount -> get_engine ( ) ; return $ engine -> getPrice ( $ originPrice , $ discount , $ request ) ; } | Computes and returns new price after using given discount |
14,271 | public static function consumeDiscount ( $ discountCode ) { $ discount = Discount_Shortcuts_GetDiscountByCodeOr404 ( $ discountCode ) ; $ engine = $ discount -> get_engine ( ) ; $ engine -> consumeDiscount ( $ discount ) ; return $ discount ; } | Decrease one unit of given discount . If discount is one - time - use it will be invalid after this function . |
14,272 | public function processStack ( $ payload , PipeChainCollectionInterface $ pipeChainCollection ) { foreach ( $ pipeChainCollection as $ stage => $ fallback ) { $ payload = $ this -> process ( $ payload , $ stage , $ fallback ) ; } return $ payload ; } | processes a PipeChainCollection with the provided payload . |
14,273 | public function fetchJSON ( $ url , $ followRedirects = true , $ username = null , $ password = null , $ headers = array ( ) ) { $ contents = $ this -> fetchURL ( $ url , $ followRedirects , $ username , $ password , $ headers ) ; return JSONUtils :: decode ( $ contents , true ) ; } | Fetch the contents of a URL as a JSON array |
14,274 | public function headURL ( $ url , $ followRedirects = true , $ username = null , $ password = null , $ headers = array ( ) ) { if ( function_exists ( 'curl_init' ) ) { $ contents = $ this -> curlRequest ( $ url , true , $ followRedirects , $ username , $ password , $ headers ) ; return $ contents ; } else { throw new H... | Fetch the headers of a URL |
14,275 | public function fetchURL ( $ url , $ followRedirects = true , $ username = null , $ password = null , $ headers = array ( ) ) { if ( function_exists ( 'curl_init' ) ) { $ contents = $ this -> curlRequest ( $ url , false , $ followRedirects , $ username , $ password , $ headers ) ; return $ contents ; } else { if ( $ th... | Fetch the contents of a URL |
14,276 | public function setPluginManager ( PluginManager $ plugins ) { $ this -> plugins = $ plugins ; $ this -> plugins -> setController ( $ this -> controller ) ; return $ this ; } | Set plugin manager |
14,277 | public function getValues ( ) { $ exploded = explode ( "," , $ this -> getValue ( ) ) ; $ values = array ( ) ; foreach ( $ exploded as $ entry ) { $ values [ ] = trim ( $ entry ) ; } return $ values ; } | Return value as an array split by |
14,278 | public static function fromGlobals ( ) { $ request = new self ( ) ; foreach ( [ 'Accept' , 'Accept-Charset' , 'Accept-Encoding' , 'Accept-Language' , 'Connection' , 'Host' , 'Referer' , 'User-Agent' ] as $ name ) { $ key = 'HTTP_' . str_replace ( '-' , '_' , strtoupper ( $ name ) ) ; if ( isset ( $ _SERVER [ $ key ] ) ... | Create request from PHP globals . |
14,279 | public function executeMigrate ( ) { $ this -> app -> eloquent -> getConnection ( ) -> useDefaultSchemaGrammar ( ) ; $ file = $ this -> app -> path [ 'app' ] -> file ( $ this -> app -> config -> get ( 'db.schema_path' , 'database/schema.php' ) ) ; if ( ! $ file -> isExists ( ) ) throw new \ Exception ( '[' . $ file . '... | Migrate eloquent schema Use db . schema_path config if configured |
14,280 | protected function elements ( $ code ) { libxml_use_internal_errors ( true ) ; $ doc = new \ DOMDocument ; $ doc -> loadHTML ( ( string ) $ code ) ; $ tag = ( string ) $ this -> tagname ; $ items = $ doc -> getElementsByTagName ( $ tag ) ; $ items = iterator_to_array ( $ items ) ; return count ( $ items ) > 0 ? $ items... | Returns elements by a tag name . |
14,281 | public function toString ( $ indent = null ) { $ output = parent :: toString ( $ indent ) ; $ output = str_replace ( [ '<title>' , '</title>' ] , [ '<h1>' , '</h1>' ] , $ output ) ; return $ output ; } | Turn helper into string |
14,282 | private function dumpXmlErrors ( $ xmlFile ) { $ severity = [ LIBXML_ERR_WARNING => 'Warning' , LIBXML_ERR_ERROR => 'Error' , LIBXML_ERR_FATAL => 'Fatal' ] ; $ errors = [ ] ; foreach ( libxml_get_errors ( ) as $ error ) { $ errors [ ] = sprintf ( "Row %d, column %d: %s (%d) %s" , $ error -> line , $ error -> column , $... | Create formatted output of XML errors |
14,283 | private function parseDbSettings ( \ DOMNode $ db ) { $ context = $ this -> isLocalhost ? 'local' : 'remote' ; $ xpath = new \ DOMXPath ( $ db -> ownerDocument ) ; $ d = $ xpath -> query ( "db_connection[@context='$context']" , $ db ) ; if ( ! $ d -> length ) { $ d = $ db -> getElementsByTagName ( 'db_connection' ) ; }... | parse db settings |
14,284 | private function parseVxpdoSettings ( \ DOMNode $ vxpdo ) { if ( is_null ( $ this -> vxpdo ) ) { $ this -> vxpdo = [ ] ; } foreach ( $ vxpdo -> getElementsByTagName ( 'datasource' ) as $ datasource ) { $ name = $ datasource -> getAttribute ( 'name' ) ? : 'default' ; if ( array_key_exists ( $ name , $ this -> vxpdo ) ) ... | parse datasource settings |
14,285 | private function parseSiteSettings ( \ DOMNode $ site ) { if ( is_null ( $ this -> site ) ) { $ this -> site = new \ stdClass ; $ this -> site -> use_nice_uris = FALSE ; } foreach ( $ site -> childNodes as $ node ) { if ( $ node -> nodeType !== XML_ELEMENT_NODE ) { continue ; } $ v = trim ( $ node -> nodeValue ) ; $ k ... | parse general website settings |
14,286 | private function parseTemplatingSettings ( \ DOMNode $ templating ) { if ( is_null ( $ this -> templating ) ) { $ this -> templating = new \ stdClass ; $ this -> templating -> filters = [ ] ; } $ xpath = new \ DOMXPath ( $ templating -> ownerDocument ) ; foreach ( $ xpath -> query ( "filters/filter" , $ templating ) as... | parse templating configuration currently only filters for SimpleTemplate templates and their configuration are parsed |
14,287 | private function parsePathsSettings ( \ DOMNode $ paths ) { if ( is_null ( $ this -> paths ) ) { $ this -> paths = [ ] ; } foreach ( $ paths -> getElementsByTagName ( 'path' ) as $ path ) { $ id = $ path -> getAttribute ( 'id' ) ; $ subdir = $ path -> getAttribute ( 'subdir' ) ? : '' ; if ( ! $ id || ! $ subdir ) { con... | parse various path setting |
14,288 | private function parseMenusSettings ( \ DOMNode $ menus ) { foreach ( ( new \ DOMXPath ( $ menus -> ownerDocument ) ) -> query ( 'menu' , $ menus ) as $ menu ) { $ id = $ menu -> getAttribute ( 'id' ) ? : Menu :: DEFAULT_ID ; if ( isset ( $ this -> menus [ $ id ] ) ) { $ this -> appendMenuEntries ( $ menu -> childNodes... | parse menu tree if menus share the same id entries of later menus are appended to the first ; other menu attributes are left unchanged |
14,289 | private function parseServicesSettings ( \ DOMNode $ services ) { if ( is_null ( $ this -> services ) ) { $ this -> services = [ ] ; } foreach ( $ services -> getElementsByTagName ( 'service' ) as $ service ) { if ( ! ( $ id = $ service -> getAttribute ( 'id' ) ) ) { throw new ConfigException ( 'Service without id foun... | parse settings for services only service id class and parameters are parsed lazy initialization is handled by Application instance |
14,290 | private function parseMenu ( \ DOMNode $ menu ) { $ root = $ menu -> getAttribute ( 'script' ) ; if ( ! $ root ) { if ( $ this -> site ) { $ root = $ this -> site -> root_document ? : 'index.php' ; } else { $ root = 'index.php' ; } } $ type = $ menu -> getAttribute ( 'type' ) === 'dynamic' ? 'dynamic' : 'static' ; $ se... | Parse XML menu entries and creates menu instance |
14,291 | public function createConst ( ) { $ properties = get_object_vars ( $ this ) ; if ( isset ( $ properties [ 'db' ] ) ) { foreach ( $ properties [ 'db' ] as $ k => $ v ) { if ( is_scalar ( $ v ) ) { $ k = strtoupper ( $ k ) ; if ( ! defined ( "DB$k" ) ) { define ( "DB$k" , $ v ) ; } } } } if ( isset ( $ properties [ 'site... | create constants for simple access to certain configuration settings |
14,292 | public function getPaths ( $ access = 'rw' ) { $ paths = [ ] ; foreach ( $ this -> paths as $ p ) { if ( $ p [ 'access' ] === $ access ) { array_push ( $ paths , $ p ) ; } } return $ paths ; } | returns all paths matching access criteria |
14,293 | private function getServerConfig ( ) { $ this -> server [ 'apc_on' ] = extension_loaded ( 'apc' ) && function_exists ( 'apc_add' ) && ini_get ( 'apc.enabled' ) && ini_get ( 'apc.rfc1867' ) ; $ fs = ini_get ( 'upload_max_filesize' ) ; $ suffix = strtoupper ( substr ( $ fs , - 1 ) ) ; switch ( $ suffix ) { case 'K' : $ m... | add particular information regarding server configuration like PHP extensions |
14,294 | public function run ( ) { $ request = $ this -> getService ( 'requestStack' ) -> getMasterRequest ( ) ; $ this -> getPreProcesses ( ) -> execute ( $ request ) ; $ response = $ this -> getFrontController ( ) -> call ( $ request ) ; $ this -> getPostProcesses ( ) -> execute ( $ response ) ; $ response -> send ( ) ; } | Sends the http response |
14,295 | public function initModules ( IModulesLoader $ modulesLoader ) { foreach ( $ modulesLoader -> getModules ( ) as $ module ) { $ this -> addModule ( $ module ) ; } } | Init the modules of the current project . |
14,296 | public function get ( $ uriPattern , callable $ controller ) { return new IRoutePatternSetterAdapter ( $ this -> getFrontController ( ) -> addController ( $ uriPattern , $ controller , 'get' ) -> getPattern ( ) ) ; } | Adds a controller called by http GET method . |
14,297 | public function post ( $ uriPattern , callable $ controller ) { return new IRoutePatternSetterAdapter ( $ this -> getFrontController ( ) -> addController ( $ uriPattern , $ controller , 'post' ) -> getPattern ( ) ) ; } | Adds a controller called by http POST method . |
14,298 | public function json ( $ uriPattern , callable $ controller ) { return new IRoutePatternSetterAdapter ( $ this -> getFrontController ( ) -> addController ( $ uriPattern , $ controller , '' , 'application/json' ) -> getPattern ( ) ) ; } | Adds a controller with a json format . |
14,299 | public function any ( $ uriPattern , callable $ controller ) { return new IRoutePatternSetterAdapter ( $ this -> getFrontController ( ) -> addController ( $ uriPattern , $ controller ) -> getPattern ( ) ) ; } | Adds a controller called by any http method or format . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.