idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
48,200 | public function convert ( $ object , $ ignoreNonSerialisables = false , $ prettyPrint = false ) { $ object = $ this -> normaliseToArrayForm ( $ object , $ ignoreNonSerialisables ) ; return json_encode ( $ object , $ prettyPrint ? JSON_PRETTY_PRINT : null ) ; } | Convert a passed object to JSON notation |
48,201 | protected function Init ( ) { $ sql = Access :: SqlBuilder ( ) ; $ tbl = Site :: Schema ( ) -> Table ( ) ; $ order = $ sql -> OrderList ( $ sql -> OrderAsc ( $ tbl -> Field ( 'Name' ) ) ) ; $ sites = Site :: Schema ( ) -> Fetch ( false , null , $ order ) ; $ this -> sites = array ( ) ; foreach ( $ sites as $ site ) { i... | Initiaizes the set of sites |
48,202 | protected function PageTreeUrl ( Site $ site ) { $ args = array ( 'site' => $ site -> GetID ( ) ) ; return BackendRouter :: ModuleUrl ( new PageTree ( ) , $ args ) ; } | Returns the page tree url of a site |
48,203 | protected function CanEdit ( Site $ site ) { return self :: Guard ( ) -> Allow ( BackendAction :: Edit ( ) , $ site ) && self :: Guard ( ) -> Allow ( BackendAction :: UseIt ( ) , new SiteForm ( ) ) ; } | True if site can be edited |
48,204 | final public function pipe ( callable $ stage , callable $ fallback = null ) : PipeChainInterface { $ this -> stack -> attach ( $ stage , $ fallback ) ; return $ this ; } | pipes a stage with an optional associated fallback . |
48,205 | final public function process ( $ payload ) { $ payload = $ this -> processor -> processStack ( $ payload , $ this -> stack ) ; if ( $ this -> next instanceof PipeChainInterface ) { $ payload = $ this -> next -> process ( $ payload ) ; } return $ payload ; } | processes a payload . |
48,206 | final public function chain ( PipeChainInterface $ chain ) : PipeChainInterface { if ( $ this -> next instanceof PipeChainInterface ) { $ this -> next -> chain ( $ chain ) ; } else { $ this -> next = $ chain ; } return $ this ; } | appends the provided pipe to the end of the chain . |
48,207 | public function spec ( $ spec , $ value = null ) { $ key = "$spec" ; if ( array_key_exists ( $ key , $ this -> spec ) ) { return $ this -> spec [ $ key ] ; } if ( ! is_null ( $ value ) ) { return $ this -> spec [ $ key ] = $ value ; } if ( is_string ( $ spec ) ) { $ spec = new CK \ MARCspec \ MARCspec ( $ spec ) ; } $ ... | Cache a spec . |
48,208 | public function validation ( $ subSpec , $ value = null ) { $ key = "$subSpec" ; if ( is_null ( $ value ) ) { if ( array_key_exists ( $ key , $ this -> valid ) ) { return $ this -> valid [ $ key ] ; } else { return ; } } $ this -> valid [ $ key ] = $ value ; } | Set or get subspec validation . |
48,209 | private function sliceData ( $ key , $ spec ) { $ start = $ spec -> getIndexStart ( ) ; if ( '#' === $ start ) { $ end = count ( $ this -> data [ $ key ] ) - 1 ; $ start = $ spec -> getIndexEnd ( ) ; if ( '#' === $ start ) { return [ $ this -> data [ $ key ] [ $ end ] ] ; } $ length = $ end - $ start ; return array_sli... | Get a slice from data . |
48,210 | public function getContents ( $ spec , array $ value = [ ] ) { if ( ! $ value ) { $ value = $ this -> getData ( "$spec" ) ; } $ substring = false ; $ charStart = null ; $ length = null ; if ( $ spec -> offsetExists ( 'charStart' ) ) { $ substring = true ; $ charStart = $ spec [ 'charStart' ] ; $ length = $ spec [ 'char... | Get referenced data content . |
48,211 | public function push ( $ key , $ value ) { $ array = $ this -> get ( $ key , [ ] ) ; if ( ! is_array ( $ array ) ) throw new JsonPropertyException ( 'Cannot push value to non array' ) ; array_push ( $ array , $ value ) ; return $ this -> set ( $ key , $ array ) ; } | Push a value into an array assigned to the provided key . |
48,212 | public function merge ( array $ values , array $ allowedKeys = [ ] ) { $ this -> data = array_merge ( $ this -> data , array_only ( $ values , array_merge ( array_keys ( $ this -> data ) , $ allowedKeys ) ) ) ; $ this -> persist ( ) ; return $ this ; } | Merge the given array into existing values . Require whitelist to add keys |
48,213 | public function forget ( $ key ) { if ( $ this -> has ( $ key ) ) { array_forget ( $ this -> data , $ key ) ; } $ this -> persist ( ) ; } | Remove element from settings array |
48,214 | public function isEmpty ( $ key ) { return ! array_has ( $ this -> data , $ key ) || filled ( array_get ( $ this -> data , $ key ) ) ; } | Check if there is a value for the given key |
48,215 | public static function retError ( $ value , $ http_code = HttpCodes :: HTTP_BAD_REQUEST , $ prettyPrint = false ) { $ response = self :: buildResponse ( $ value , false , $ http_code ) ; return self :: retJSON ( $ response , $ prettyPrint ) ; } | Return error . |
48,216 | public static function buildResponse ( $ value , $ success , $ httpCode , Paginer $ pagingInfo = null ) { $ response = new stdClass ( ) ; $ response -> success = $ success ; $ response -> http_code = $ httpCode ; if ( $ pagingInfo ) { $ response -> pageNumber = $ pagingInfo -> getPageNumber ( ) ; $ response -> pageSize... | Builds API response . |
48,217 | public static function retSuccess ( $ value = null , $ http_code = HttpCodes :: HTTP_OK , Paginer $ pagingInfo = null , $ prettyPrint = false ) { $ response = self :: buildResponse ( $ value , true , $ http_code , $ pagingInfo ) ; return self :: retJSON ( $ response , $ prettyPrint ) ; } | Return success . |
48,218 | public static function isSuccess ( stdClass $ response ) { if ( is_object ( $ response ) && $ response -> success == true ) { return HttpCodes :: isOk ( $ response -> http_code ) ; } else { return false ; } } | Check if a response is a success . |
48,219 | private function set ( $ operand , $ value ) { $ reflector = $ this -> getReflector ( ) ; if ( ! $ reflector -> hasProperty ( $ operand ) ) { throw new RuntimeException ( 'Trying to access undefined property in reflection context: ' . $ operand ) ; } $ reflectionProperty = $ reflector -> getProperty ( $ operand ) ; if ... | Reflection property setter . |
48,220 | private function get ( $ operand ) { $ reflector = $ this -> getReflector ( ) ; if ( ! $ reflector -> hasProperty ( $ operand ) ) { throw new RuntimeException ( 'Trying to access undefined property from reflection context: ' . $ operand ) ; } $ reflectionProperty = $ reflector -> getProperty ( $ operand ) ; if ( $ refl... | Reflected p [ roperties defauilt getter . |
48,221 | public static function substring ( $ string , $ start = 0 , $ length = null ) { if ( ! self :: isValid ( $ string ) ) { return false ; } return mb_substr ( $ string , $ start , $ length ) ; } | Get a part of a string |
48,222 | public static function startsWith ( $ needle , $ haystack , $ caseSensitive = true ) { if ( ! self :: isValid ( $ needle ) ) { return false ; } list ( $ needle , $ haystack ) = self :: transformCase ( $ needle , $ haystack , $ caseSensitive ) ; if ( $ needle === false ) { return false ; } else { return ( self :: substr... | Check if string starts with another string |
48,223 | public static function endsWith ( $ needle , $ haystack , $ caseSensitive = true ) { list ( $ needle , $ haystack ) = self :: transformCase ( $ needle , $ haystack , $ caseSensitive ) ; return ( self :: substring ( $ haystack , - ( self :: length ( $ needle ) ) ) === $ needle ) ; } | Check if string ends with another string |
48,224 | public static function contains ( $ needle , $ haystack , $ caseSensitive = true ) { if ( ! self :: isValid ( $ haystack ) ) { return false ; } list ( $ needle , $ haystack ) = self :: transformCase ( $ needle , $ haystack , $ caseSensitive ) ; return ( mb_strpos ( $ haystack , $ needle ) !== false ) ; } | Check if string contains another string |
48,225 | public static function replace ( $ search , $ replace , $ string , $ caseSensitive = true ) { if ( ! self :: isValid ( $ replace ) ) { return false ; } if ( ! $ caseSensitive ) { return str_ireplace ( $ search , $ replace , $ string ) ; } else { return str_replace ( $ search , $ replace , $ string ) ; } } | Replace a string with another string |
48,226 | public static function isEmpty ( $ string ) { if ( ! self :: isValid ( $ string ) && null !== $ string ) { return false ; } return ( $ string === null || $ string === '' ) ; } | Check if string is empty |
48,227 | public static function isNotEmpty ( $ string ) { if ( ! self :: isValid ( $ string ) && null !== $ string ) { return false ; } return ( ! self :: isEmpty ( $ string ) ) ; } | Check if string is not empty |
48,228 | static function Trans ( $ text , $ from_charset , $ to_charset , $ options = array ( ) ) { $ from_charset = self :: _GetCharsetByName ( $ from_charset ) ; $ to_charset = self :: _GetCharsetByName ( $ to_charset ) ; if ( $ from_charset == $ to_charset ) { return $ text ; } return self :: _Trans ( $ text , $ from_charset... | Converts string from source charset to target charset . |
48,229 | static function Lower ( $ text , $ charset = null ) { static $ TR_TABLES = array ( ) ; $ charset = self :: _GetCharsetByName ( $ charset ) ; switch ( $ charset ) { case "windows-1250" : case "iso-8859-2" : if ( ! isset ( $ TR_TABLES [ $ charset ] ) ) { require ( dirname ( __FILE__ ) . "/tr_tables/lower_upper/$charset.p... | Converts string to lowercase . |
48,230 | static function Upper ( $ text , $ charset = null ) { static $ TR_TABLES = array ( ) ; $ charset = self :: _GetCharsetByName ( $ charset ) ; switch ( $ charset ) { case "windows-1250" : case "iso-8859-2" : if ( ! isset ( $ TR_TABLES [ $ charset ] ) ) { require ( dirname ( __FILE__ ) . "/tr_tables/lower_upper/$charset.p... | Converts string to uppercase . |
48,231 | static function CheckEncoding ( $ text , $ charset , $ disallowed_char_sequencies = array ( ) ) { if ( is_array ( $ text ) ) { foreach ( $ text as $ _key => $ _value ) { $ _stat_key = self :: CheckEncoding ( $ _key , $ charset , $ disallowed_char_sequencies ) ; $ _stat_value = self :: CheckEncoding ( $ _value , $ chars... | Checks if input string is in given charset . |
48,232 | static function Length ( & $ text , $ charset ) { $ charset = self :: _GetCharsetByName ( $ charset ) ; switch ( $ charset ) { case "utf8" : return self :: _LengthUtf8 ( $ text ) ; default : return strlen ( $ text ) ; } } | Counts length of a string . |
48,233 | public function asc ( array $ collection ) { $ count = count ( $ collection ) ; if ( $ count < 2 ) { return $ collection ; } $ leftCollection = array ( ) ; $ rightCollection = array ( ) ; reset ( $ collection ) ; $ sortPivot = key ( $ collection ) ; $ pivot = array_shift ( $ collection ) ; foreach ( $ collection as $ k... | Sorts the given array using a quick sort algorithm . |
48,234 | public function desc ( array $ collection ) { $ this -> changeDirection ( false ) ; $ collection = $ this -> asc ( $ collection ) ; $ this -> changeDirection ( true ) ; return $ collection ; } | Inversely sorts the given array using a quick sort algorithm |
48,235 | private function getNamespace ( $ class , $ source , $ destination ) { if ( false === is_object ( $ class ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type object, "%s" given' , __METHOD__ , gettype ( $ class ) ) , E_USER_ERROR ) ; } if ( false === is_array ( $ source ) ) { return tr... | Returns the path of a giving namespace |
48,236 | public static function normalizePath ( $ path ) { if ( is_string ( $ path ) ) { return explode ( '.' , $ path ) ; } if ( ! is_array ( $ path ) ) { return [ $ path ] ; } return $ path ; } | Normalize property paths . |
48,237 | public function count ( ) { $ result = 0 ; foreach ( $ this -> routes as $ routes ) { $ result += count ( $ routes ) ; } return $ result ; } | Returns the number of key - value mappings in the router map . |
48,238 | public function containsCallable ( callable $ callable ) { foreach ( $ this -> routes as $ method ) { foreach ( $ method as $ entry ) { if ( $ entry -> callable === $ callable ) { return true ; } } } return false ; } | Returns true if the router map maps one or more routes to the specified callable . |
48,239 | public function get ( $ method , $ route ) { if ( ! array_key_exists ( $ method , $ this -> routes ) ) { return null ; } foreach ( $ this -> routes [ $ method ] as $ key => $ entry ) { if ( $ entry -> route == $ route ) { return $ entry -> callable ; } } return null ; } | Returns the callable to which the specified route is mapped or null if the router map contains no mapping for the route . |
48,240 | public function set ( $ methods , $ route , callable $ callable ) { if ( is_string ( $ methods ) ) { $ methods = [ $ methods ] ; } foreach ( $ methods as $ method ) { $ this -> add ( $ method , $ route , $ callable ) ; } return $ this ; } | Associates the specified callable with the specified method & route in the route map . |
48,241 | private function add ( string $ method , string $ route , callable $ callable ) { $ entry = ( object ) [ 'route' => $ route , 'pattern' => $ this -> createPattern ( $ route ) , 'callable' => $ callable ] ; if ( ! array_key_exists ( $ method , $ this -> routes ) ) { $ this -> routes [ $ method ] = [ ] ; } $ this -> rout... | Adds a method & route to the to the route map . |
48,242 | public function remove ( $ method , $ route ) { if ( ! array_key_exists ( $ method , $ this -> routes ) ) { return ; } foreach ( $ this -> routes [ $ method ] as $ key => $ entry ) { if ( $ entry -> route == $ route ) { unset ( $ this -> routes [ $ method ] [ $ key ] ) ; } } if ( count ( $ this -> routes [ $ method ] )... | Removes the mapping for the specified route from the router map if present . |
48,243 | public function resolve ( $ method = null , $ route = null ) { $ serverRequest = new ServerRequest ( ) ; if ( $ method === null ) { $ method = $ serverRequest -> getMethod ( ) ; } if ( $ route === null ) { $ route = $ serverRequest -> getUri ( ) -> getPath ( ) ; } if ( $ this -> basePath !== '' && strpos ( $ route , $ ... | Returns the result of the given route s callable . |
48,244 | private function getCallable ( $ method , $ route ) { if ( ! array_key_exists ( $ method , $ this -> routes ) ) { throw new ServerResponseException ( new ServerResponse ( 404 ) ) ; } foreach ( $ this -> routes [ $ method ] as $ entry ) { if ( preg_match ( $ entry -> pattern , $ route , $ matches ) > 0 ) { array_shift (... | Returns the callable to which the specied method and route are mapped . |
48,245 | public function set ( $ name , $ value = null , $ time = 2592000 ) { $ value = json_encode ( $ value ) ; parent :: set ( $ name , $ value ) ; setcookie ( $ name , $ value , time ( ) + $ time , '/' , $ this -> server -> get ( 'name' ) ) ; } | Set cookie information . |
48,246 | public function seed ( array $ roles ) { Role :: query ( ) -> insert ( $ this -> prepareRoles ( $ roles ) ) ; $ this -> syncAdminRole ( ) ; } | Seed roles . |
48,247 | protected function prepareRoles ( array $ roles ) { $ now = now ( ) ; return array_map ( function ( $ role ) use ( $ now ) { return array_merge ( $ role , [ 'slug' => $ role [ 'slug' ] ?? $ this -> slugify ( $ role [ 'name' ] ) , 'is_locked' => $ role [ 'is_locked' ] ?? true , 'created_at' => $ now , 'updated_at' => $ ... | Prepare roles to seed . |
48,248 | protected function syncAdminRole ( ) { $ admin = Role :: admin ( ) -> first ( ) ; $ admin -> permissions ( ) -> sync ( Permission :: all ( ) -> pluck ( 'id' ) -> toArray ( ) ) ; } | Sync the admin role with all permissions . |
48,249 | protected function syncRoles ( array $ roles ) { $ permissions = Permission :: all ( ) ; foreach ( $ roles as $ roleSlug => $ permissionSlug ) { if ( $ role = Role :: query ( ) -> where ( 'slug' , $ roleSlug ) -> first ( ) ) { $ filtered = $ permissions -> filter ( function ( Permission $ permission ) use ( $ permissio... | Sync the roles . |
48,250 | public function cmdGetProduct ( ) { $ result = $ this -> getListProduct ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableProduct ( $ result ) ; $ this -> output ( ) ; } | Callback for product - get command |
48,251 | public function cmdUpdateProduct ( ) { $ 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 product - update command |
48,252 | protected function addProduct ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> product -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } } | Add a new product |
48,253 | protected function submitAddProduct ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> setSubmitted ( 'form' , true ) ; $ this -> validateComponent ( 'product' ) ; $ this -> addProduct ( ) ; } | Add a new product at once |
48,254 | protected function wizardAddProduct ( ) { $ this -> validatePrompt ( 'title' , $ this -> text ( 'Title' ) , 'product' ) ; $ this -> validatePrompt ( 'description' , $ this -> text ( 'Description' ) , 'product' ) ; $ this -> validatePrompt ( 'store_id' , $ this -> text ( 'Store ID' ) , 'product' , 0 ) ; $ this -> valida... | Add a new product step by step |
48,255 | public function getClassNames ( $ withNamespace = true ) { $ tokens = new \ PHP_Token_Stream ( $ this -> _content ) ; $ classes = $ tokens -> getClasses ( ) ; $ classNames = array ( ) ; foreach ( $ classes as $ className => $ class ) { $ namespace = $ class [ 'package' ] [ 'namespace' ] ; if ( $ withNamespace === true ... | Get class names defined in target file |
48,256 | public function cmdGetCollection ( ) { $ result = $ this -> getListCollection ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableCollection ( $ result ) ; $ this -> output ( ) ; } | Callback for collection - get command |
48,257 | public function cmdDeleteCollection ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( empty ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ options = null ; if ( isset ( $ id ) ) { if ( $ this -> getParam ( 'type' ) ) { $ options = ... | Callback for collection - delete command |
48,258 | public function cmdUpdateCollection ( ) { $ 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' ) ) ; } $ th... | Callback for collection - update command |
48,259 | protected function addCollection ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> collection -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } } | Add a new collection |
48,260 | protected function submitAddCollection ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'collection' ) ; $ this -> addCollection ( ) ; } | Add a new collection at once |
48,261 | protected function wizardAddCollection ( ) { $ this -> validatePrompt ( 'title' , $ this -> text ( 'Title' ) , 'collection' ) ; $ this -> validateMenu ( 'type' , $ this -> text ( 'Type' ) , 'collection' , $ this -> collection -> getTypes ( ) ) ; $ this -> validatePrompt ( 'store_id' , $ this -> text ( 'Store' ) , 'coll... | Add a new collection step by step |
48,262 | public function create ( $ timestamps = true , $ softDeletes = false , $ fields = [ ] ) { $ path = $ this -> getpath ( $ this -> name ) ; if ( $ this -> files -> exists ( $ path ) ) { throw new \ Exception ( "Factory [$this->name] already exists!" ) ; } $ stub = $ this -> files -> get ( $ this -> getStub ( ) ) ; $ stub... | Create a new factory file . |
48,263 | public function getPath ( $ name ) { $ segments = explode ( '\\' , $ name ) ; array_shift ( $ segments ) ; if ( $ this -> path ) return $ this -> path . '/' . ucfirst ( array_last ( $ segments ) ) . 'Factory.php' ; else return database_path ( 'factories/' . ucfirst ( array_last ( $ segments ) ) ) . 'Factory.php' ; } | Get path for migration file . |
48,264 | protected function replaceFakerArray ( & $ stub , $ fields , $ timestamps , $ softDeletes ) { $ array = [ ] ; foreach ( $ fields as $ f ) { if ( ! empty ( $ f [ 'fakerFunction' ] ) || ! empty ( $ f [ 'fkey' ] ) ) { $ params = ! empty ( $ f [ 'fakerFunctionParams' ] ) ? "({$f['fakerFunctionParams']})" : "" ; if ( ! empt... | Replace Faker array dummy . |
48,265 | public function getIsNode ( ) { return ! is_null ( $ this -> domNode ) && isset ( DOMXPathNavigator :: $ nodeTypeMap [ $ this -> domNode -> nodeType ] ) ; } | Gets a value indicating whether the item represents an XPath node or an atomic value |
48,266 | public function getValue ( ) { if ( is_null ( $ this -> domNode ) ) { return "" ; } if ( $ this -> domNode instanceof \ DOMNameSpaceNode ) { $ ns = $ this -> domNode ; return $ ns -> nodeValue ; } return $ this -> domNode instanceof \ DOMDocument ? $ this -> domNode -> textContent : $ this -> domNode -> nodeValue ; } | Gets the string value of the item |
48,267 | public function getValueType ( ) { $ xmlType = SchemaTypes :: getInstance ( ) -> getTypeForDOMNode ( $ this -> domNode ) ; if ( $ xmlType ) { $ type = Type :: XmlTypeToPHPType ( $ xmlType ) ; if ( $ type ) return $ type ; } return Type :: string ; } | Gets the PHP runtime type of the item . |
48,268 | public function getXmlType ( ) { if ( ! property_exists ( $ this -> domNode , "schemaType" ) ) { $ effectiveNode = $ this -> domNode -> nodeType == XML_TEXT_NODE ? $ this -> domNode -> parentNode : $ this -> domNode ; $ this -> domNode -> schemaType = DOMSchemaType :: getSchemaType ( $ effectiveNode ) ; } return $ this... | When overridden in a derived class gets the XmlSchemaType for the item . |
48,269 | public function createSession ( ) { if ( ! isset ( $ _SESSION ) ) { if ( PHP_SAPI === 'cli' ) { $ _SESSION = array ( ) ; } elseif ( ! headers_sent ( ) ) { if ( ! session_start ( ) ) { throw new SessionException ( 'session_start failed.' ) ; } } else { throw new SessionException ( 'Session started after headers sent.' )... | Init session parameters and init the class to manage the vars . |
48,270 | protected function buildStatusCodes ( array $ data ) { if ( isset ( $ data [ 'statusCodes' ] ) ) { $ this -> initializeStatusCodes ( ) ; foreach ( $ data [ 'statusCodes' ] as $ key => $ element ) { if ( ( int ) $ key < 200 ) { $ this -> statusCodes ( $ element ) ; } else { $ this -> statusCodes ( $ key , $ element ) ; ... | Loads data given status codes . |
48,271 | protected function statusCodes ( $ statusCode , $ customDescription = null ) { if ( $ customDescription ) { $ description = $ customDescription ; } if ( $ customDescription !== null || array_key_exists ( $ statusCode , $ this -> defaultStatusCodes ) ) { if ( ! isset ( $ description ) ) { $ description = $ this -> defau... | Method that allows to choose between status code passing the code and optional description . |
48,272 | protected function initializeStatusCodes ( ) { $ annotationReflection = new \ ReflectionClass ( 'Nelmio\ApiDocBundle\Annotation\ApiDoc' ) ; $ statusCodesReflection = $ annotationReflection -> getProperty ( 'statusCodes' ) ; $ statusCodesReflection -> setAccessible ( true ) ; $ statusCodesReflection -> setValue ( $ this... | Purges the statusCodes array to populate with the new way . |
48,273 | public function setCentrifuge ( $ centrifuge = array ( ) ) { if ( is_array ( $ centrifuge ) && $ centrifuge ) { $ this -> centrifuge = $ centrifuge ; return true ; } throw new InvalidArgumentException ( 'Invalid argument given' ) ; } | This method sets the centrifuge property |
48,274 | public function put ( $ data ) { if ( ! $ data instanceof DataTransferObject ) { throw new Exception ( 'You are trying to put invalid object to trunk.' ) ; } if ( ! array_key_exists ( $ data -> getType ( ) , $ this -> storage ) ) { $ this -> storage [ $ data -> getType ( ) ] = [ ] ; } $ storageKey = $ this -> storageKe... | Add item or collection to trunk |
48,275 | public function has ( $ key , $ type ) { if ( is_array ( $ key ) ) { return $ this -> hasItem ( $ this -> storageKey ( $ key ) , $ type ) ; } if ( is_string ( $ key ) ) { return $ this -> hasItem ( $ key , $ type ) ; } if ( is_int ( $ key ) ) { return $ this -> hasItem ( $ this -> storageKey ( [ $ key ] ) , $ type ) ; ... | Check cache for item or collection |
48,276 | protected function hasItem ( $ key , $ type ) { if ( array_key_exists ( $ type , $ this -> storage ) && array_key_exists ( $ key , $ this -> storage [ $ type ] ) ) { return true ; } return false ; } | Check if item exists in cache |
48,277 | public function get ( $ key , $ type ) { if ( is_array ( $ key ) ) { return $ this -> getItem ( $ this -> storageKey ( $ key ) , $ type ) ; } if ( is_string ( $ key ) ) { return $ this -> getItem ( $ key , $ type ) ; } if ( is_int ( $ key ) ) { return $ this -> getItem ( $ this -> storageKey ( [ $ key ] ) , $ type ) ; ... | Get item or collection from cache |
48,278 | protected function getItem ( $ key , $ type ) { if ( array_key_exists ( $ type , $ this -> storage ) && array_key_exists ( $ key , $ this -> storage [ $ type ] ) ) { return $ this -> storage [ $ type ] [ $ key ] ; } return null ; } | Get item by id and type |
48,279 | protected function getRoutedParameter ( $ parameter , $ default = null ) { $ output = $ default ; $ parameters = $ this -> route -> getParameters ( ) ; if ( ! empty ( $ parameters -> $ parameter ) ) { $ output = $ parameters -> $ parameter ; } $ validatedData = $ this -> route -> getValidatedData ( ) ; if ( ! empty ( $... | Function for retrieving routed parameter data from the stored Route reference |
48,280 | public function exists ( $ key ) { $ key = $ this -> secureKey ( $ key ) ; if ( isset ( $ _SESSION [ $ key ] ) ) return true ; return false ; } | Checks if a session variable exists |
48,281 | public function set ( $ key , $ value ) { $ key = $ this -> secureKey ( $ key ) ; $ _SESSION [ $ key ] = $ this -> secureValue ( $ value ) ; return $ key ; } | Creates a new session or sets an existing sesssion |
48,282 | public function get ( $ key ) { $ key = $ this -> secureKey ( $ key ) ; if ( isset ( $ _SESSION [ $ key ] ) ) { return trim ( Text :: unlock ( $ _SESSION [ $ key ] , $ this -> sugar ( ) ) ) ; } else { return '' ; } } | Gets session variable s value |
48,283 | protected function appendSingleFormFields ( FormBuilderInterface $ formBuilder ) { $ defaultOptions = [ 'label' => $ this -> getTitle ( ) , 'required' => false , ] ; $ userOptions = array_key_exists ( 'single' , $ this -> getFormOptions ( ) ) ? $ this -> getFormOptions ( ) [ 'single' ] : [ ] ; if ( count ( $ userOption... | Appends form fields for single mode . |
48,284 | protected function appendRangedFormFields ( FormBuilderInterface $ formBuilder ) { $ fromDefaultOptions = [ 'label' => 'da2e.filtration.number_filter.ranged.from.label' , 'required' => false , ] ; $ fromUserOptions = array_key_exists ( 'ranged_from' , $ this -> getFormOptions ( ) ) ? $ this -> getFormOptions ( ) [ 'ran... | Appends form fields for range mode . |
48,285 | public function addSitemapItem ( $ postValues ) { $ sitemapObject = SitemapItemFactory :: createSitemapItemFromPostValues ( $ postValues ) ; $ sitemap = $ this -> repository -> sitemap ; $ sitemap [ ] = $ sitemapObject ; $ this -> repository -> sitemap = $ sitemap ; $ this -> save ( ) ; } | Add a sitemap item |
48,286 | public function getSitemapItemBySlug ( $ slug ) { $ sitemap = $ this -> repository -> sitemap ; foreach ( $ sitemap as $ sitemapItem ) { if ( $ sitemapItem -> slug == $ slug ) { return $ sitemapItem ; } } return null ; } | Get a sitemap item by its slug |
48,287 | private function addRoute ( $ types = '' , $ uri , $ action = [ ] ) { if ( is_string ( $ action ) ) { $ action = [ '_controller' => $ action ] ; } if ( is_array ( $ action ) ) { if ( isset ( $ action [ 'as' ] ) ) { AsCollector :: addAs ( $ action [ 'as' ] , $ uri ) ; } } $ types = ( array ) $ types ; foreach ( $ types ... | Add a route with type uri and action parameters |
48,288 | protected function createWhenUri ( $ uri ) { $ when = static :: $ firing [ 'when' ] ; if ( substr ( $ when , - 1 ) !== '/' ) { $ when .= '/' ; } if ( substr ( $ uri , 0 , 1 ) === '/' ) { $ uri = substr ( $ uri , 1 , strlen ( $ uri ) ) ; } return $ when . $ uri ; } | prapare uri to merge with when url and return it . |
48,289 | public function group ( $ name , $ action , Closure $ callback ) { static :: $ groups [ $ name ] = [ 'action' => $ action , 'callback' => $ callback ] ; return $ this ; } | register a new group collection |
48,290 | public function triggerEvent ( string $ event ) : void { if ( $ this -> file instanceof ICacheStateful ) { switch ( $ event ) { case self :: EVENT_CACHED : $ this -> file -> setCachedAt ( $ this -> name , time ( ) ) ; break ; case self :: EVENT_EMPTY : case self :: EVENT_ERROR : case self :: EVENT_NOT_FOUND : $ this ->... | Call user function after saving cached file |
48,291 | private function doXssClean ( $ data ) { if ( is_array ( $ data ) && count ( $ data ) ) { foreach ( $ data as $ k => & $ v ) { $ v = $ this -> doXssClean ( $ data [ $ k ] ) ; } return $ data ; } if ( trim ( $ data ) === '' ) { return $ data ; } $ data = str_replace ( [ '&' , '<' , '>' ] , [ '&amp;' , '&am... | Do XSS Clean |
48,292 | public function getConfig ( ) { return array ( 'baseUrl' => Yii :: app ( ) -> getBaseUrl ( true ) , 'base_url' => Yii :: app ( ) -> getBaseUrl ( true ) . '/hybridauth/callback' , 'debug_mode' => YII_DEBUG , 'debug_file' => Yii :: getPathOfAlias ( 'application.runtime.hybridauth' ) . '.log' , 'providers' => CMap :: merg... | Convert configuration to an array for Hybrid_Auth rather than object properties as supplied by Yii |
48,293 | public static function db ( ) { self :: $ conn -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION ) ; return self :: $ conn ; } | Get an instance of the db connection |
48,294 | public function fields ( array $ fields ) { $ newFields = array ( ) ; $ this -> fields = '' ; $ this -> fieldsArguments = array ( ) ; foreach ( $ fields as $ field ) { if ( is_scalar ( $ field ) ) { $ newFields [ ] = '?f:alias:.?f' ; $ this -> fieldsArguments [ ] = $ field ; } else { if ( ! isset ( $ field [ 0 ] ) or !... | Sets fields statement |
48,295 | public function join ( $ tableName , $ alias = null ) { $ this -> joins [ ] = ' LEFT JOIN ?f as ?f' ; $ this -> lastJoinAlias = $ alias ; $ this -> joinArguments [ ] = $ tableName ; $ this -> joinArguments [ ] = $ alias ; return $ this ; } | Sets one field in fields statement |
48,296 | protected function orderByDirection ( $ field , $ direction , $ prefixWithTableAlias = true ) { $ aliasInsert = $ prefixWithTableAlias ? '?f:alias:.' : '' ; if ( $ this -> orderSql == '' ) { $ this -> orderSql = " ORDER BY {$aliasInsert}?f {$direction}" ; } else { $ this -> orderSql .= ", {$aliasInsert}?f {$direction}"... | Sets order by statement |
48,297 | protected function importItems ( \ DOMDocument $ xml ) { foreach ( $ xml -> documentElement -> getElementsByTagName ( 'item' ) as $ item ) { $ dom = simplexml_import_dom ( $ item ) ; $ this -> addMenuItem ( $ dom ) ; } } | Parses DOM element and adds it as an admin menu item |
48,298 | protected function addMenuItem ( \ SimpleXMLElement $ item ) { $ em = $ this -> doctrineHelper -> getEntityManager ( ) ; $ adminMenuItem = $ this -> adminMenuRepository -> findOneBy ( [ 'identifier' => ( string ) $ item -> identifier ] ) ; $ parent = $ this -> adminMenuRepository -> findOneBy ( [ 'identifier' => ( stri... | Creates new admin menu item |
48,299 | private function resolveRulePrototype ( ) { if ( ! isset ( $ this -> routeTypeRulePrototypeMap [ $ this -> routeType ] ) ) { throw new RuntimeException ( "Unable to resolve rule for route type '$this->routeType'. Route type is not supported." ) ; } $ prototypeClass = $ this -> routeTypeRulePrototypeMap [ $ this -> rout... | Resolve the rule prototype object for the current routeType |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.