idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
54,400 | public function update ( array $ values ) : int { $ this -> coerceDataTypesToDatabase ( $ values ) ; return $ this -> builder -> update ( $ values ) ; } | Update a record in the database |
54,401 | protected function generateTree ( Collection $ collection , Collection $ children ) { $ children -> map ( function ( AdminMenuInterface $ menuItem ) use ( $ collection , & $ tree ) { $ tree [ ] = [ 'routeName' => $ menuItem -> getRouteName ( ) , 'cssClass' => $ menuItem -> getCssClass ( ) , 'name' => $ menuItem -> getN... | Generates a tree for given children elements |
54,402 | protected function injectToolbar ( Response $ response , $ params ) { if ( function_exists ( 'mb_stripos' ) ) { $ posrFunction = 'mb_strripos' ; $ substrFunction = 'mb_substr' ; } else { $ posrFunction = 'strripos' ; $ substrFunction = 'substr' ; } $ content = $ response -> getContent ( ) ; if ( false !== $ pos = $ pos... | Injects the Terrific Composer Toolbar into the given Response . |
54,403 | public function parseCommand ( $ originCommand ) { $ mappings = [ 'create' => [ 'create' ] , 'drop' => [ 'drop' , 'dropIfExists' ] , ] ; foreach ( $ mappings as $ key => $ mapping ) { if ( in_array ( $ originCommand , $ mapping ) ) { return $ key ; } } return null ; } | Parse origin command to human command |
54,404 | public function primary ( $ columns , $ name = null ) { $ this -> addCachePrimary ( $ columns ) ; return parent :: primary ( $ columns , $ name ) ; } | Store list primary to create i18n |
54,405 | public function build ( Connection $ connection , Grammar $ grammar ) { $ command = $ this -> parseCommand ( $ this -> commands [ 0 ] -> get ( 'name' ) ) ; $ schema = $ connection -> getSchemaBuilder ( ) ; if ( $ command === "drop" ) { $ schema -> dropIfExists ( $ this -> getI18NTableName ( ) ) ; } parent :: build ( $ ... | Overrride build function |
54,406 | protected function createColumn ( $ name , $ type , array $ parameters = [ ] ) { $ attributes = array_merge ( compact ( 'type' , 'name' ) , $ parameters ) ; $ column = new Fluent ( $ attributes ) ; return $ column ; } | Create column fluent |
54,407 | public function i18n_string ( $ name , $ length = 255 ) { $ this -> i18n_columns [ ] = $ column = $ this -> createColumn ( $ name , 'string' , compact ( 'length' ) ) ; return $ column ; } | Add i18n string field |
54,408 | public function i18n_char ( $ name , $ length = 255 ) { $ this -> i18n_columns [ ] = $ column = $ this -> createColumn ( $ name , 'char' , compact ( 'length' ) ) ; return $ column ; } | Add i18n char field |
54,409 | private function setHandle ( $ mode ) { $ this -> closeExistingHandle ( ) ; $ this -> handle = fopen ( $ this -> file , $ mode ) ; return $ this -> handle ; } | Set file handle |
54,410 | public function write ( $ string , $ append = true ) { $ mode = $ this -> getMode ( $ append ) ; $ this -> setHandle ( $ mode ) ; return fwrite ( $ this -> handle , $ string ) ; } | Write a string into a file |
54,411 | public function read ( $ length = 0 , $ asArray = false ) { if ( $ asArray && Number :: isZero ( $ length ) ) { return file ( $ this -> file ) ; } elseif ( Number :: isPositive ( $ length ) ) { $ this -> setHandle ( 'r' ) ; return fread ( $ this -> handle , $ length ) ; } else { return Collection :: implode ( $ this ->... | Read content from file |
54,412 | public function getSessionData ( $ key ) { self :: ensureSession ( ) ; if ( ! isset ( $ _SESSION [ $ key ] ) ) { return null ; } return $ _SESSION [ $ key ] ; } | Get data from session |
54,413 | private function initHeaders ( ) { if ( $ this -> headers !== null ) { return ; } $ apacheHeaders = function_exists ( 'apache_request_headers' ) ? apache_request_headers ( ) : false ; if ( $ apacheHeaders ) { foreach ( $ apacheHeaders as $ key => $ val ) { $ this -> headers [ strtoupper ( $ key ) ] = $ val ; } } else {... | Initialise the header list |
54,414 | public function getHeader ( $ name ) { $ this -> initHeaders ( ) ; $ name = strtoupper ( $ name ) ; if ( ! isset ( $ this -> headers [ $ name ] ) ) { return false ; } return $ this -> headers [ $ name ] ; } | Get a request header or false if it isn t set |
54,415 | public function tryLastModified ( $ modifiedTime ) { $ clientCache = $ this -> getHeader ( 'If-Modified-Since' ) ; if ( $ clientCache !== false ) { $ clientCache = preg_replace ( '/;.*$/' , '' , $ clientCache ) ; $ clientCacheTime = @ strtotime ( $ clientCache ) ; if ( $ modifiedTime <= $ clientCacheTime ) { header ( '... | Respond with 304 Last Modified if appropiate |
54,416 | public static function parse ( string $ url , string $ default_scheme = null ) { if ( substr ( $ url , 0 , 4 ) === "www." && ! empty ( $ default_scheme ) ) $ url = $ default_scheme . '://' . $ url ; elseif ( substr ( $ url , 0 , 2 ) === '//' && ! empty ( $ _SERVER [ 'REQUEST_SCHEME' ] ) ) $ url = $ _SERVER [ 'REQUEST_S... | Parse a URL |
54,417 | protected static function parseQuery ( $ query ) { if ( is_array ( $ query ) ) return $ query ; if ( empty ( $ query ) ) return null ; if ( ! is_string ( $ query ) ) throw new \ InvalidArgumentException ( 'Query must be associative array or string' ) ; $ query = ltrim ( $ query , '?' ) ; $ query = str_replace ( '&'... | Parse a query string or array |
54,418 | public function setPath ( string $ path ) { $ path = '/' . ltrim ( $ path , '/' ) ; $ this -> query = null ; $ this -> fragment = null ; if ( preg_match ( '/^(.*?)(\\?([^#]*))?(#(.*))?$/u' , $ path , $ matches ) ) { $ path = $ matches [ 1 ] ; $ this -> query = ! empty ( $ matches [ 3 ] ) ? $ matches [ 3 ] : null ; $ th... | Set the path of the URL . This will unset the currently set fragment and query and overwrite them with whatever is appended in the path . |
54,419 | public function toString ( bool $ idn = false ) { $ o = "" ; if ( ! empty ( $ this -> scheme ) ) $ o .= $ this -> scheme . "://" ; if ( ! empty ( $ this -> username ) && ! empty ( $ this -> password ) ) $ o .= $ this -> username . ':' . $ this -> password . '@' ; $ host = $ this -> host ; if ( $ idn && preg_match ( '/[... | Convert a URL to a string . |
54,420 | public function setHost ( string $ hostname ) { if ( ( $ ppos = strrpos ( $ hostname , ":" ) ) !== false ) { $ this -> port = substr ( $ hostname , $ ppos + 1 ) ; $ hostname = substr ( $ hostname , 0 , $ ppos ) ; } if ( substr ( $ hostname , 0 , 4 ) === "xn--" ) $ hostname = \ idn_to_utf8 ( $ hostname ) ; $ this -> hos... | Set the host name of the URL |
54,421 | public function set ( string $ field , $ value ) { if ( $ value === null ) $ value = "" ; switch ( $ field ) { case "scheme" : $ this -> scheme = strtolower ( $ value ) ; return $ this ; case "port" : $ value = empty ( $ value ) ? null : ( int ) $ value ; case "username" : case "password" : case "fragment" : $ this -> ... | Set a field to a new value |
54,422 | public function get ( string $ field ) { if ( $ field === "secure" ) return $ this -> scheme === "https" ; if ( $ field === "port" && $ this -> port === null ) { if ( $ this -> scheme === "http" ) return 80 ; if ( $ this -> scheme === "https" ) return 443 ; if ( $ this -> scheme === "ftp" ) return 21 ; } if ( $ field =... | Get the value for a field |
54,423 | public function setQueryVariable ( string $ key , string $ value ) { if ( empty ( $ value ) ) unset ( $ this -> query [ $ key ] ) ; else $ this -> query [ $ key ] = $ value ; return $ this ; } | Set or update a query variable |
54,424 | public function getVendorPath ( ) { if ( is_null ( $ this -> vendorPath ) ) { $ installPath = $ this -> composer -> getInstallationManager ( ) -> getInstallPath ( $ this -> package ) ; $ targetDir = $ this -> package -> getName ( ) ; $ this -> vendorPath = explode ( $ targetDir , $ installPath ) [ 0 ] ; } return $ this... | Returns the vendor path of the current package |
54,425 | public function install ( ) { $ packages = $ this -> composer -> getPackage ( ) -> getRequires ( ) ; foreach ( $ packages as $ package ) { $ this -> packagesStatuses [ $ package -> getTarget ( ) ] = array ( 'extra' => null , 'dirs' => null ) ; $ this -> installPackage ( $ package ) ; } return $ this ; } | Installs all the assets directories of the dependency packages |
54,426 | public function installPackage ( $ package ) { $ jsonData = $ this -> getPackageJsonFile ( $ package ) ; $ packagesAssetsDir = $ this -> getPackageAssetsDirs ( $ jsonData ) ; if ( ! is_null ( $ packagesAssetsDir ) ) { $ this -> log ( $ package -> getTarget ( ) , self :: LOG_INFO , self :: CODE_INSTALLING_PACKAGE ) ; $ ... | Installs all the assets directories of the given package |
54,427 | public function getPackageJsonFile ( $ package ) { $ vendorPath = $ this -> getVendorPath ( ) ; $ targetDir = $ package -> getTarget ( ) ; $ jsonPath = $ vendorPath . $ targetDir . "/composer.json" ; if ( method_exists ( $ package , 'getJsonFile' ) ) { $ jsonFile = $ package -> getJsonFile ( $ jsonPath ) ; } else { $ j... | Returns the Json file of the given Package |
54,428 | public function getPackageAssetsDirs ( $ jsonData ) { $ packagesAssetsDir = null ; if ( isset ( $ jsonData [ "extra" ] [ self :: LABEL_ASSETS_DIR ] ) ) { $ packagesAssetsDir = $ jsonData [ "extra" ] [ self :: LABEL_ASSETS_DIR ] ; if ( is_string ( $ packagesAssetsDir ) ) { $ packagesAssetsDir = array ( self :: LABEL_PUB... | Returns all the assets directories contained in the given jsonData |
54,429 | public function installPackageDir ( $ package , $ namespace , $ packageAssetsDir ) { $ this -> log ( $ package -> getTarget ( ) , self :: LOG_INFO , self :: CODE_INSTALLING_DIR , array ( 'namespace' => $ namespace ) ) ; if ( ! isset ( $ this -> assetsDirectories [ $ namespace ] ) ) { $ this -> log ( $ package -> getTar... | Installs a specific directory from the given package |
54,430 | public function setCast ( $ option , $ type ) { if ( ! $ this -> isDefined ( $ option ) ) { throw new UndefinedOptionsException ( sprintf ( 'The option "%s" does not exist. Defined options are: "%s".' , $ option , implode ( '", "' , $ this -> getDefinedOptions ( ) ) ) ) ; } if ( $ type instanceof \ Closure ) { $ refClo... | Sets a cast for a specific option . The given option will be cast to the given type before any validation if possible . |
54,431 | protected function clearUndefinedOptions ( array $ options , $ allowUndefinedOptions ) { if ( ! $ allowUndefinedOptions ) { return $ options ; } $ undefinedOptions = array_diff ( array_keys ( $ options ) , $ this -> getDefinedOptions ( ) ) ; return array_diff_key ( $ options , array_flip ( $ undefinedOptions ) ) ; } | Clears undefined options before resolving if the appropriate flag is set . |
54,432 | protected function resolveCasts ( array $ options = [ ] ) { $ castOptions = $ options ; foreach ( $ options as $ option => $ value ) { if ( ! isset ( $ this -> casts [ $ option ] ) ) { continue ; } $ type = $ this -> casts [ $ option ] ; $ castOptions [ $ option ] = ( $ type instanceof \ Closure ) ? $ type ( $ value ) ... | Resolves a variable casts in the initial options . |
54,433 | protected function castToType ( $ value , $ type ) { switch ( $ type ) { case self :: TYPE_CAST_INT : $ newValue = filter_var ( $ value , FILTER_VALIDATE_INT , FILTER_NULL_ON_FAILURE ) ; $ value = ( null === $ newValue ) ? $ value : $ newValue ; break ; case self :: TYPE_CAST_BOOL : $ newValue = filter_var ( $ value , ... | Applies specific cast logic for each type . |
54,434 | public function add ( Annotation $ annotation ) { if ( ! isset ( $ this -> types [ $ annotation -> type ( ) ] ) ) { $ this -> types [ $ annotation -> type ( ) ] = [ $ annotation ] ; } else { $ this -> types [ $ annotation -> type ( ) ] [ ] = $ annotation ; } return $ this ; } | adds given annotation |
54,435 | public function firstNamed ( string $ type ) : Annotation { if ( $ this -> contain ( $ type ) ) { return $ this -> types [ $ type ] [ 0 ] ; } throw new \ ReflectionException ( 'Can not find annotation ' . $ type . ' for ' . $ this -> target ) ; } | returns first annotation with given type name |
54,436 | public function addAlias ( string $ alias , string $ original ) : self { $ this -> aliases [ $ alias ] = $ original ; return $ this ; } | Adds an alias |
54,437 | public function addTag ( string $ tagName , string $ src ) : self { $ this -> tagNames [ $ tagName ] = $ src ; return $ this ; } | Defines a new tag |
54,438 | public function make ( ) { if ( self :: $ newComponentCache === null ) { self :: $ newComponentCache = new \ IvoPetkov \ BearFramework \ Addons \ HTMLServerComponents \ Internal \ Component ( ) ; } return clone ( self :: $ newComponentCache ) ; } | Creates new component and return it |
54,439 | private function createCreateForm ( Country $ entity ) { $ form = $ this -> createForm ( new CountryType ( $ this -> get ( 'doctrine.orm.entity_manager' ) -> getRepository ( 'OrkestroLocaleBundle:Locale' ) ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'orkestro_backend_country_create' ) , 'method' => 'POST... | Creates a form to create a Country entity . |
54,440 | public function newAction ( ) { $ entity = new Country ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; } | Displays a form to create a new Country entity . |
54,441 | public function showAction ( $ iso_code ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'OrkestroCountryBundle:Country' ) -> findOneBy ( array ( 'isoCode' => $ iso_code , ) ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Country entity.' ) ; ... | Finds and displays a Country entity . |
54,442 | public function editAction ( $ iso_code ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( 'OrkestroCountryBundle:Country' ) -> findOneBy ( array ( 'isoCode' => $ iso_code , ) ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Country entity.' ) ; ... | Displays a form to edit an existing Country entity . |
54,443 | private function createEditForm ( Country $ entity ) { $ form = $ this -> createForm ( new CountryType ( $ this -> get ( 'doctrine.orm.entity_manager' ) -> getRepository ( 'OrkestroLocaleBundle:Locale' ) ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'orkestro_backend_country_update' , array ( 'iso_code' =>... | Creates a form to edit a Country entity . |
54,444 | private function createDeleteForm ( $ iso_code ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'orkestro_backend_country_delete' , array ( 'iso_code' => $ iso_code ) ) ) -> setMethod ( 'DELETE' ) -> add ( 'submit' , 'submit' , array ( 'label' => 'Delete' ) ) -> getForm ( ) ; } | Creates a form to delete a Country entity by iso code . |
54,445 | protected function _createOutOfBoundsException ( $ message = null , $ code = null , RootException $ previous = null , $ argument = null ) { return new OutOfBoundsException ( $ message , $ code , $ previous , $ argument ) ; } | Creates a new Dhii Out Of Bounds exception . |
54,446 | public static function replace_key ( array $ array , $ oldKey , $ newKey ) : array { $ newArray = array ( ) ; foreach ( $ array as $ key => $ value ) { if ( $ key == $ oldKey ) { $ newArray = array_merge ( $ newArray , [ $ newKey => $ value ] ) ; } else { $ newArray = array_merge ( $ newArray , [ $ key => $ value ] ) ;... | Replace array key |
54,447 | public function set ( string $ uri , int $ method , callable $ action , bool $ default = false ) : self { if ( ( self :: METHOD_ANY & $ method ) !== $ method ) { throw new Exception \ InvalidMethodException ( "Route does not contain a valid HTTP Method." ) ; } $ this -> uri = "~" ; foreach ( explode ( "|" , $ uri ) as ... | Set Route data |
54,448 | public function set404Route ( callable $ action ) : self { $ this -> uri = "404RouteNotFound" ; $ this -> method = self :: METHOD_ANY ; $ this -> action = $ action ; $ this -> is404 = true ; return $ this ; } | Set 404 Route |
54,449 | protected function iterate ( $ value , PropertyDefinitionInterface $ definition = null ) { if ( empty ( $ value ) || ! is_array ( $ value ) ) { return $ value ; } $ type = $ definition -> getGenericType ( ) ; foreach ( $ value as $ key => $ item ) { if ( is_null ( $ item ) ) { continue ; } $ value [ $ key ] = $ this ->... | Attempte to iterate the value and cast all child items to the require generic type . |
54,450 | protected function castValue ( $ value , $ type ) { if ( isset ( $ this -> scalarMap [ $ type ] ) ) { $ cast = $ this -> castToScalar ( $ value , $ this -> scalarMap [ $ type ] ) ; return $ cast == $ value ? $ cast : $ value ; } if ( is_null ( $ value ) ) { return null ; } if ( ! is_array ( $ value ) && $ type === 'arr... | Cast a value to the desired type non - destructively . |
54,451 | protected function castToScalar ( $ value , $ type ) { if ( $ type === 'integer' ) { return ( integer ) $ value ; } if ( $ type === 'boolean' ) { return ( boolean ) $ value ; } if ( $ type === 'float' ) { return ( float ) $ value ; } if ( $ type === 'string' ) { return ( string ) $ value ; } return $ value ; } | Cast a value to the desired scalar type . Value remains unchanged if type is not scalar . |
54,452 | public function loadPlugins ( $ plugins ) { foreach ( $ plugins as $ plugin ) { $ pluginClass = str_replace ( ':' , '\\' , $ plugin ) ; $ this -> plugins [ ] = new $ pluginClass ( $ this -> core ) ; } } | Load all plugins from an array |
54,453 | public function invokePluginHook ( $ hookName ) { $ args = func_get_args ( ) ; array_shift ( $ args ) ; foreach ( $ this -> plugins as $ plugin ) { if ( method_exists ( $ plugin , $ hookName ) === false ) continue ; call_user_func_array ( array ( $ plugin , $ hookName ) , $ args ) ; } } | Invokes a specific plugin hook |
54,454 | protected function load ( $ field ) { if ( ! is_null ( $ this -> $ field ) || ! $ this -> delegatesCollection || ! $ this -> delegatesCollection -> containsKey ( $ key = strtolower ( $ field ) ) ) { return $ this -> $ field ; } $ loader = $ this -> delegatesCollection -> get ( $ key ) ; $ this -> delegatesCollection ->... | Load given field if able to define his value and return it . |
54,455 | protected function setMetas ( $ title = null , $ description = null ) { $ meta = Config :: getInstance ( ) -> get ( 'Eureka\Global\Meta' ) ; if ( $ title !== null ) { $ meta [ 'title' ] = strip_tags ( $ title . ' - ' . $ meta [ 'title' ] ) ; } if ( $ description !== null ) { $ meta [ 'description' ] = strip_tags ( $ de... | Override meta description with given description . |
54,456 | public static function statusClassFor ( int $ statusCode ) : string { $ class = substr ( ( string ) $ statusCode , 0 , 1 ) ; return self :: $ statusClass [ $ class ] ?? self :: STATUS_CLASS_UNKNOWN ; } | returns status class for given status code |
54,457 | public static function reasonPhraseFor ( int $ statusCode ) : string { if ( isset ( self :: $ reasonPhrases [ $ statusCode ] ) ) { return self :: $ reasonPhrases [ $ statusCode ] ; } throw new \ InvalidArgumentException ( 'Invalid or unknown HTTP status code ' . $ statusCode ) ; } | returns reason phrase for given status code |
54,458 | public static function lines ( string ... $ lines ) : string { $ head = true ; return join ( '' , array_map ( function ( $ line ) use ( & $ head ) { if ( empty ( $ line ) && $ head ) { $ head = false ; return self :: emptyLine ( ) ; } if ( $ head ) { return self :: line ( $ line ) ; } return $ line ; } , $ lines ) ) ; ... | creates valid http lines from given input lines |
54,459 | public static function isValidRfc ( string $ rfc ) : bool { return in_array ( $ rfc , [ self :: RFC_2616 , self :: RFC_7230 ] ) ; } | checks if given RFC is a valid and known RFC |
54,460 | public function toModel ( ) { $ nodeClass = $ this -> getElement ( ) -> NodeClass ; if ( $ nodeClass === 'Node' ) { throw new LogicException ( 'You must set a custom node in <node_class/> for element: ' . $ this -> getElement ( ) -> getSlug ( ) ) ; } else { throw new LogicException ( 'You must create a toModel method i... | You must implement a toModel method in a subclass of Node defined in a plugin . xml or system . xml in order to have toModel functionality . |
54,461 | public function setNodeRef ( $ newNodeRef ) { $ this -> fields [ 'NodeRef' ] = $ newNodeRef ; $ this -> fields [ 'Slug' ] = $ newNodeRef -> isFullyQualified ( ) ? $ newNodeRef -> getSlug ( ) : '' ; } | Changes our NodeRef |
54,462 | public function setSlug ( $ slug ) { if ( empty ( $ this -> fields [ 'Slug' ] ) || empty ( $ this -> fields [ 'OriginalSlug' ] ) ) { $ this -> fields [ 'NodeRef' ] = new NodeRef ( $ this -> getNodeRef ( ) -> getElement ( ) , $ slug ) ; } $ this -> fields [ 'Slug' ] = $ slug ; } | Sets the Slug |
54,463 | public function getNodePartials ( ) { if ( ! array_key_exists ( 'NodePartials' , $ this -> fields ) || is_null ( $ this -> fields [ 'NodePartials' ] ) ) $ this -> fields [ 'NodePartials' ] = new NodePartials ( ) ; return $ this -> fields [ 'NodePartials' ] ; } | Returns a reference to the partials for this node . |
54,464 | public function redirectMatching ( Request $ request ) { $ redirects = $ this -> storage -> getRedirects ( ) -> getRedirects ( ) ; $ relativeUri = '/' . $ request :: $ relativeUri ; foreach ( $ redirects as $ redirect ) { if ( preg_match_all ( $ redirect -> fromUrl , $ relativeUri , $ matches ) ) { $ toUrl = preg_repla... | Loop through the redirects and see if a redirect needs to take place |
54,465 | public function sitemapMatching ( $ request ) { $ sitemap = $ this -> storage -> getSitemap ( ) -> getSitemap ( ) ; $ relativeUri = '/' . $ request :: $ relativeUri ; foreach ( $ sitemap as $ sitemapItem ) { if ( $ sitemapItem -> regex ) { $ matches = array ( ) ; if ( preg_match_all ( $ sitemapItem -> url , $ relativeU... | Loop through sitemap items and see if one matches the requestUri . If it does add it tot the matchedSitemapItems array |
54,466 | public function connect ( $ host , $ port , $ secure = true ) { $ this -> socket -> setBlocking ( false ) ; if ( ! $ this -> socket -> connect ( $ host , $ port , $ secure ) ) { throw new Exception \ ConnectionFailedException ( sprintf ( '%s failed to %s:%d with error %s (%d).' , $ secure ? 'Secure connection' : 'Conne... | Set up a connection to the server . |
54,467 | protected function read ( ) { $ data = '' ; do { if ( $ this -> socket -> closed ( ) ) { throw new Exception \ ConnectionDroppedException ( 'The connection has been dropped.' ) ; } $ data .= $ this -> socket -> read ( ) ; } while ( ! preg_match ( $ this -> responseEnding , $ data ) ) ; return utf8_decode ( substr ( $ d... | Retrieve a response from the server . |
54,468 | public function getResponse ( RequestInterface $ request ) { $ this -> write ( $ request -> getPacket ( ) ) ; return $ request -> getResponse ( ) -> init ( $ this -> read ( ) ) ; } | Send a request to the server and construct an appropriate response . |
54,469 | public function setTransactionMethod ( $ method ) { if ( ! is_array ( $ this -> transactionMethods ) ) { $ this -> transactionMethods = [ $ method ] ; return $ this ; } if ( ! in_array ( $ method , $ this -> transactionMethods ) ) { $ this -> transactionMethods [ ] = $ method ; } return $ this ; } | Set transaction method . |
54,470 | public function removeTransactionMethod ( $ method ) { if ( ! is_array ( $ this -> transactionMethods ) ) { return $ this ; } $ index = array_search ( $ method , $ this -> transactionMethods ) ; if ( $ index !== false ) { array_splice ( $ this -> transactionMethods , $ index , 1 ) ; } if ( empty ( $ this -> transaction... | Remove transaction method . |
54,471 | protected function proxy ( $ method , $ args ) { $ this -> beforeProxy ( $ method , $ args ) ; $ result = call_user_func_array ( array ( $ this , $ method ) , $ args ) ; $ this -> afterProxy ( $ method , $ args , $ result ) ; return $ result ; } | Proxy function through which domain methods will be called This method should be overridden in extending classes |
54,472 | protected function beforeProxy ( $ method , $ args ) { if ( is_array ( $ this -> transactionMethods ) && in_array ( $ method , $ this -> transactionMethods ) ) { $ this -> db -> beginTransaction ( ) ; } } | Logic before proxy call to domain method |
54,473 | protected function afterProxy ( $ method , $ args , $ result ) { if ( is_array ( $ this -> transactionMethods ) && in_array ( $ method , $ this -> transactionMethods ) ) { $ this -> db -> commit ( ) ; } } | Logic after proxy call to domain method |
54,474 | public function update ( $ id , $ model ) { $ args = func_get_args ( ) ; $ result = $ this -> proxy ( '_update' , $ args ) ; return $ result ; } | DB UPDATE of object |
54,475 | public function post2FALogin ( Request $ request ) { $ userId = $ request -> session ( ) -> get ( 'user_id' ) ; if ( $ this -> twoFactorAuthHelper -> isTwoFactorAuthFormTimeout ( $ userId ) ) { return view ( 'usermanagement::frontend.' . $ this -> frontend_template_name . '.login.login' , [ 'title' => 'Login' , ] ) -> ... | Handle the front - end Two Factor Authorization login |
54,476 | public function request ( $ endpoint , $ isPost = false , $ params = array ( ) ) { $ accessToken = $ this -> getAccessToken ( ) ; if ( $ accessToken === null ) { return null ; } $ params [ 'accessToken' ] = $ accessToken -> getAccessToken ( ) ; $ url = $ this -> getConfig ( ) -> getApiUrl ( ) . $ endpoint ; if ( ! $ is... | Request an API endpoint with post or get method and given parameters . Returns null if no AccessToken is provided |
54,477 | private function evaluateDirectory ( $ directory = null ) { $ directory = $ this -> setDirectoryFallback ( $ directory ) ; $ this -> run ( $ directory ) ; } | Walk through directory |
54,478 | public function remove ( $ key ) { if ( $ key instanceof UniqueId ) { $ key = $ key -> id ( ) ; } return $ this -> elements -> remove ( $ key ) ; } | Removes the element at the specified index from the collection . |
54,479 | public function map ( Closure $ func ) { return new static ( $ this -> type , $ this -> elements -> map ( $ func ) -> toArray ( ) ) ; } | Applies the given public function to each element in the collection and returns a new collection with the elements returned by the public function . |
54,480 | public static function validate ( $ data , $ type , callable $ filter = null ) { $ type = strtoupper ( $ type ) ; if ( ! array_key_exists ( $ type , self :: $ supported_types ) ) { throw new UnexpectedValueException ( "Bad validation type" ) ; } return call_user_func ( self :: $ supported_types [ $ type ] , $ data , $ ... | Generic validator . |
54,481 | public static function validateString ( $ data , callable $ filter = null ) { if ( is_string ( $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; } | String validator . |
54,482 | public static function validateBoolean ( $ data , callable $ filter = null ) { if ( is_bool ( $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; } | Bool validator . |
54,483 | public static function validateInteger ( $ data , callable $ filter = null ) { if ( is_int ( $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; } | Int validator . |
54,484 | public static function validateNumeric ( $ data , callable $ filter = null ) { if ( is_numeric ( $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; } | Numeric validator . |
54,485 | public static function validateFloat ( $ data , callable $ filter = null ) { if ( is_float ( $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; } | Float validator . |
54,486 | public static function validateJson ( $ data , callable $ filter = null ) { $ decoded = json_decode ( $ data ) ; if ( is_null ( $ decoded ) ) return false ; return self :: applyFilter ( $ data , $ filter ) ; } | Json validator . |
54,487 | public static function validateSerialized ( $ data , callable $ filter = null ) { $ decoded = @ unserialize ( $ data ) ; if ( $ decoded === false && $ data != @ serialize ( false ) ) return false ; return self :: applyFilter ( $ data , $ filter ) ; } | Serialized values validator . |
54,488 | public static function validateDatetimeIso8601 ( $ data , callable $ filter = null ) { if ( DateTime :: createFromFormat ( DateTime :: ATOM , $ data ) === false ) return false ; return self :: applyFilter ( $ data , $ filter ) ; } | Iso8601 - datetime validator . |
54,489 | public static function validateBase64 ( $ data , callable $ filter = null ) { return base64_encode ( base64_decode ( $ data , true ) ) === $ data ? self :: applyFilter ( $ data , $ filter ) : false ; } | Base64 validator . |
54,490 | public function load ( array $ configs , ContainerBuilder $ container ) { $ configuration = new Configuration ( ) ; $ config = $ this -> processConfiguration ( $ configuration , $ configs ) ; $ loader = new XmlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/config' ) ) ; $ loader -> load ( 'toolba... | Loads the terrific composer configuration . |
54,491 | protected function parseFragment ( $ name ) { $ fileName = $ this -> loader -> findFilename ( $ name ) ; $ html5 = new HTML5 ( ) ; $ dom = $ html5 -> loadHTMLFragment ( file_get_contents ( $ fileName ) ) ; if ( $ html5 -> getErrors ( ) ) { $ errors = "" ; foreach ( $ html5 -> getErrors ( ) as $ error ) { $ errors .= "\... | Parses an HTML Togu component |
54,492 | public static function underscoreToCamelCase ( $ string ) { static $ cache = array ( ) ; if ( array_key_exists ( $ string , $ cache ) == true ) { return $ cache [ $ string ] ; } $ replacer = function ( array $ matches ) { return strtoupper ( $ matches [ 1 ] ) ; } ; return $ cache [ $ string ] = preg_replace_callback ( ... | Convert a underscore defined string to his camelCase format |
54,493 | public static function camelCaseToUnderscore ( $ string ) { static $ cache = array ( ) ; if ( array_key_exists ( $ string , $ cache ) === true ) { return $ cache [ $ string ] ; } $ replacer = function ( array $ matches ) { return '_' . strtolower ( $ matches [ 0 ] ) ; } ; return $ cache [ $ string ] = preg_replace_call... | Convert a camelCased defined string to his underscore format |
54,494 | public function setStream ( PsrStreamInterface $ stream ) { $ this -> stream = $ stream ; $ this -> error = UPLOAD_ERR_OK ; return true ; } | Set the stream which this uploaded file refers to . |
54,495 | public function addImageSizeDefinition ( ImageResizeDefinition $ ird ) { $ this -> image_resize_definitions [ $ ird -> getWidth ( ) ] = $ ird ; ksort ( $ this -> image_resize_definitions ) ; } | Add another allowed image size |
54,496 | public function getImageResizeDefinitionForWidth ( $ width , $ fit_in_width = false ) { if ( empty ( $ this -> image_resize_definitions ) ) { return null ; } if ( $ fit_in_width ) { foreach ( $ this -> image_resize_definitions as $ w => $ ird ) { if ( $ w > $ width && isset ( $ prev_ird ) ) { return $ prev_ird ; } else... | Get nearest available ImageSizeDefinition for given screen width |
54,497 | protected function isCachedById ( int $ id , int $ siteId = null ) { $ siteId = SiteHelper :: resolveSiteId ( $ siteId ) ; if ( ! isset ( $ this -> cacheById [ $ siteId ] ) ) { $ this -> cacheById [ $ siteId ] = [ ] ; } return array_key_exists ( $ id , $ this -> cacheById [ $ siteId ] ) ; } | Identify whether in cached by ID |
54,498 | public static function getEnv ( ) { if ( null !== ( getenv ( 'P_DRIVER' ) ) ) { $ dotEnv = new Dotenv ( $ _SERVER [ 'DOCUMENT_ROOT' ] ) ; $ dotEnv -> load ( ) ; } self :: $ driver = getenv ( 'P_DRIVER' ) ; self :: $ host = getenv ( 'P_HOST' ) ; self :: $ dbname = getenv ( 'P_DBNAME' ) ; self :: $ user = getenv ( 'P_USE... | Get environment values from . env file |
54,499 | public static function connect ( ) { self :: getEnv ( ) ; return new PDO ( self :: $ driver . ':host=' . self :: $ host . ';dbname=' . self :: $ dbname , self :: $ user , self :: $ pass ) ; } | Create PDO connections |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.