idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
15,700 | final public function getError ( $ i = null , $ toString = true ) { if ( $ i === null ) { $ error = end ( self :: $ errors ) ; } else if ( ! array_key_exists ( $ i , self :: $ errors ) ) { return false ; } else { $ error = self :: $ errors [ $ i ] ; } return $ error ; } | Returns a referenced error |
15,701 | final public function getErrorString ( ) { $ errors = self :: getErrors ( ) ; $ string = '<ul>' ; foreach ( $ errors as $ error ) { $ string .= '<li>' . $ error . '</li>' ; } return $ string . '</ul>' ; } | Returns the error string |
15,702 | public function set ( $ property , $ value = null , $ overwrite = false ) { $ previous = isset ( $ this -> $ property ) ? $ this -> $ property : null ; $ this -> $ property = $ value ; return $ previous ; } | Sets an object property |
15,703 | final private function referencedArgs ( & $ arr ) { if ( strnatcmp ( phpversion ( ) , '5.3' ) >= 0 ) { $ refs = array ( ) ; foreach ( $ arr as $ key => $ value ) $ refs [ ] = & $ arr [ $ key ] ; return $ refs ; } return $ arr ; } | Solution to passing data by reference |
15,704 | public function itemsFilterIds ( $ params ) { if ( empty ( $ params [ 'orderby' ] ) ) { $ params [ 'orderby' ] = $ this -> leftKeyName ; } return parent :: itemsFilterIds ( $ params ) ; } | Filters items and return array of IDs |
15,705 | public function itemsFilterHash ( $ params ) { $ db = \ Brilliant \ BFactory :: getDBO ( ) ; $ itemshash = parent :: itemsFilterHash ( $ params ) ; if ( isset ( $ params [ 'level' ] ) ) { $ itemshash .= ':level=' . $ params [ 'level' ] ; } if ( isset ( $ params [ 'parent' ] ) ) { $ itemshash .= ':parent=' . $ params [ ... | News categories tree cache hash . |
15,706 | public function getSimpleTreeRecursive ( $ fields = array ( ) , $ transfields = array ( ) , $ lang = '' , $ wh = array ( ) ) { $ list = $ this -> getSimpleTree ( $ fields , $ transfields , $ lang , $ wh ) ; if ( ! is_array ( $ list ) ) { return array ( ) ; } $ tree = array ( ) ; foreach ( $ list as $ li ) { $ id = ( in... | Get recursive tree |
15,707 | public function setCache ( $ cachetime , $ etag = true ) { $ this -> _cachetime = $ cachetime ; $ this -> _cacheetag = $ etag ; } | Sets the caching time for the current page . |
15,708 | public function getAll ( $ handle ) { array_unshift ( $ this -> _header , 'Content-Type: text/html; charset=utf-8' ) ; $ this -> _header [ ] = 'Vary:' ; rewind ( $ handle ) ; $ hash = hash_init ( 'md5' ) ; hash_update_stream ( $ hash , $ handle ) ; $ hash = hash_final ( $ hash ) ; $ hash = md5 ( $ hash . implode ( '' ,... | Returns all headers for a given content . This is internally used by the \ Morrow \ Core \ Frontcontroller class . |
15,709 | public function DataUrl ( $ relativeOrAbsolutePath ) { $ currentDirFullPath = $ this -> view -> GetCurrentViewDirectory ( ) ; $ searchedPaths = [ ] ; array_unshift ( $ searchedPaths , $ currentDirFullPath . '/' . $ relativeOrAbsolutePath ) ; if ( ! file_exists ( $ searchedPaths [ 0 ] ) ) { array_unshift ( $ searchedPat... | Return any file content by given relative or absolute path in data url . Path could be relative from currently rendered view relative from application root or absolute path to file . |
15,710 | protected function registerSearchSettings ( array $ config , ContainerBuilder $ container ) { if ( empty ( $ config [ 'configs' ] ) ) { throw ConfigManagerException :: error ( 'At least 1 configuration should be present under configs.' ) ; } $ definition = $ container -> getDefinition ( 'rz_search.manager.config' ) ; f... | Registers ckeditor widget . |
15,711 | public function render ( $ template , $ data = null ) { $ twig = $ this -> getTwig ( ) ; $ parser = $ twig -> loadTemplate ( $ template ) ; return $ parser -> render ( $ this -> all ( ) , $ data ) ; } | Custom render method |
15,712 | public function add ( MetaSetInterface $ metaSet ) { $ this -> metaSets [ $ metaSet -> getId ( ) ] = $ metaSet ; $ this -> nameMap [ $ metaSet -> getName ( ) ] = $ metaSet -> getId ( ) ; return $ this ; } | Add meta set . |
15,713 | public static function Config ( $ Name = FALSE , $ Default = FALSE ) { $ Config = self :: $ _Config ; if ( $ Name === FALSE ) $ Result = $ Config ; else $ Result = $ Config -> Get ( $ Name , $ Default ) ; return $ Result ; } | Get a configuration setting for the application . |
15,714 | public static function Controller ( $ Value = NULL ) { static $ Controller = NULL ; if ( $ Value !== NULL ) $ Controller = $ Value ; return $ Controller ; } | The current controller being targetted . |
15,715 | public static function Factory ( $ Alias = FALSE ) { if ( is_null ( self :: $ _Factory ) ) { self :: SetFactory ( new Gdn_Factory ( ) ) ; self :: FactoryOverwrite ( FALSE ) ; } if ( $ Alias === FALSE ) return self :: $ _Factory ; $ Args = func_get_args ( ) ; array_shift ( $ Args ) ; return self :: $ _Factory -> Factory... | Get an object from the factory . |
15,716 | public static function FactoryInstallDependency ( $ Alias , $ PropertyName , $ SourceAlias ) { self :: Factory ( ) -> InstallDependency ( $ Alias , $ PropertyName , $ SourceAlias ) ; } | Installs a dependency to the factory . |
15,717 | public static function FactoryInstallDependencyFromConfig ( $ Config , $ Alias = NULL ) { if ( is_string ( $ Config ) ) $ Config = self :: Config ( $ Config ) ; if ( is_null ( $ Alias ) ) $ Alias = $ Config [ 'Alias' ] ; $ PropertyName = $ Config [ 'PropertyName' ] ; $ SourceAlias = $ Config [ 'SourceAlias' ] ; $ Overr... | Installs a dependency to the factory with the settings from a configuration . |
15,718 | public static function FactoryInstallFromConfig ( $ Config , $ Alias = NULL ) { if ( is_string ( $ Config ) ) $ Config = self :: Config ( $ Config ) ; if ( is_null ( $ Alias ) ) $ Alias = $ Config [ 'Alias' ] ; $ FactoryType = $ Config [ 'FactoryType' ] ; $ Data = ArrayValue ( 'Data' , $ Config , NULL ) ; $ Override = ... | Installs a class to the factory with the settings from a configuration . |
15,719 | public static function Request ( $ NewRequest = NULL ) { $ Request = self :: $ _Request ; if ( ! is_null ( $ NewRequest ) ) { if ( is_string ( $ NewRequest ) ) $ Request -> WithURI ( $ NewRequest ) ; elseif ( is_object ( $ NewRequest ) ) $ Request -> FromImport ( $ NewRequest ) ; } return $ Request ; } | Get or set the current request object . |
15,720 | public static function Slice ( $ Slice ) { $ Result = self :: Factory ( self :: AliasSlice ) ; return $ Result -> Execute ( $ Slice ) ; } | Get a reference to the Gdn_Slice |
15,721 | public static function SetFactory ( $ Factory , $ Override = TRUE ) { if ( $ Override || is_null ( self :: $ _Factory ) ) self :: $ _Factory = $ Factory ; } | Set the object used as the factory for the api . |
15,722 | public function execute ( TallantoMethodInterface $ method ) { $ options = [ ] ; if ( $ method instanceof AbstractSecuredTallantoMethod ) { if ( $ method -> isSecured ( ) ) { $ options [ 'auth' ] = [ $ method -> getLogin ( ) , $ method -> getPassword ( ) ] ; } } if ( ! is_null ( $ jsonData = $ method -> getJsonData ( )... | Executes API method . |
15,723 | public function writeToFile ( $ filename , $ data , $ header = '' ) { $ ini = $ this -> writeToString ( $ data , $ header ) ; if ( ! file_put_contents ( $ filename , $ ini ) ) throw new IniWritingException ( sprintf ( 'Impossible to write to file %s' , $ filename ) ) ; } | Convert an array or an IniCollection to INI string in file . |
15,724 | public function writeToString ( $ data , $ header = '' ) { if ( $ data instanceof IniCollection ) $ data = $ data -> toArray ( ) ; else if ( ! is_array ( $ data ) ) throw new IniWritingException ( 'The expected type is array or \NoczCore\Ini\IniCollection' ) ; $ ini = '' ; if ( ! empty ( $ header ) ) $ ini .= $ header ... | Convert an array or an IniCollection to INI string . |
15,725 | private function convertRecursive ( array $ array , $ parentKey = null ) { $ return = [ ] ; if ( ! is_null ( $ parentKey ) ) $ parentKey .= '.' ; foreach ( $ array as $ k => $ v ) { if ( is_array ( $ v ) ) $ return [ ] = $ this -> convertRecursive ( $ v , $ parentKey . $ k ) ; else $ return [ $ parentKey . $ k ] = $ v ... | Transform a recursive array to a basic array with a point for the recursive keys . |
15,726 | private function encode ( $ value ) { if ( $ value === true ) $ value = "true" ; else if ( $ value === false ) $ value = "false" ; else if ( is_string ( $ value ) ) $ value = "\"$value\"" ; return $ value ; } | Encode value . |
15,727 | public static function forge ( $ body = null , $ status = 200 , array $ headers = array ( ) ) { $ response = new static ( $ body , $ status , $ headers ) ; \ Event :: instance ( ) -> has_events ( 'response_created' ) and \ Event :: instance ( ) -> trigger ( 'response_created' , '' , 'none' ) ; return $ response ; } | Creates an instance of the Response class |
15,728 | public static function redirect_back ( $ url = '' , $ method = 'location' , $ code = 302 ) { if ( $ referrer = \ Input :: referrer ( ) ) { if ( strpos ( $ referrer , \ Uri :: base ( ) ) === 0 and $ referrer != \ Uri :: current ( ) ) { static :: redirect ( $ referrer , $ method , $ code ) ; } } static :: redirect ( $ ur... | Redirects back to the previous page if that page is within the current application . If not it will redirect to the given url and if none is given back to the application root |
15,729 | public function set_header ( $ name , $ value , $ replace = true ) { if ( $ replace ) { $ this -> headers [ $ name ] = $ value ; } else { $ this -> headers [ ] = array ( $ name , $ value ) ; } return $ this ; } | Adds a header to the queue |
15,730 | public function get_header ( $ name = null ) { if ( func_num_args ( ) ) { return isset ( $ this -> headers [ $ name ] ) ? $ this -> headers [ $ name ] : null ; } else { return $ this -> headers ; } } | Gets header information from the queue |
15,731 | public function send_headers ( ) { if ( ! headers_sent ( ) ) { if ( ! empty ( $ _SERVER [ 'FCGI_SERVER_VERSION' ] ) ) { header ( 'Status: ' . $ this -> status . ' ' . static :: $ statuses [ $ this -> status ] ) ; } else { $ protocol = \ Input :: server ( 'SERVER_PROTOCOL' ) ? \ Input :: server ( 'SERVER_PROTOCOL' ) : '... | Sends the headers if they haven t already been sent . Returns whether they were sent or not . |
15,732 | public function send ( $ send_headers = false ) { $ body = $ this -> __toString ( ) ; if ( $ send_headers ) { $ this -> send_headers ( ) ; } if ( $ this -> body != null ) { echo $ body ; } } | Sends the response to the output buffer . Optionally will send the headers . |
15,733 | public static function fromFile ( string $ file , string $ driver = null ) : ConfigInterface { if ( ! $ driver ) { $ ext = strtolower ( ( string ) pathinfo ( $ file , PATHINFO_EXTENSION ) ) ; if ( $ ext === 'yml' ) { $ ext = ConfigAdapterInterface :: ADAPTER_YAML ; } $ driver = isset ( static :: $ availableAdapter [ $ ... | Get from file |
15,734 | public function didef ( $ thing , $ file ) { $ this -> thingList [ $ thing ] = $ file ; $ args = func_get_args ( ) ; array_shift ( $ args ) ; array_shift ( $ args ) ; if ( count ( $ args ) ) { $ this -> thingArgList [ $ thing ] = $ args ; } } | Define a file as a thing . Any extra arguments are saved and used as constructor arguments |
15,735 | public function attachServices ( $ obj ) { $ args = get_class_vars ( get_class ( $ obj ) ) ; foreach ( $ args as $ _k => $ _v ) { if ( substr ( $ _k , - 7 ) == 'Service' ) { $ obj -> $ _k = _makePromise ( $ _k ) ; } } } | Set a DI promise object on every class var that ends with Service |
15,736 | private function validateCustomerBalance ( $ balance , $ amount , $ useDelta = false ) { if ( $ useDelta ) { $ result = ( ( $ balance + self :: CONVERSION_DELTA ) >= $ amount ) ; } else { $ result = ( $ balance >= $ amount ) ; } return $ result ; } | Customer balance should be greater or equal to transaction amount . |
15,737 | public function rootPath ( ) { return ( 'phar:' === substr ( $ this -> basePath , 0 , 5 ) ) ? dirname ( str_replace ( 'phar://' , '' , $ this -> basePath ) ) : $ this -> basePath ; } | Get the path of root |
15,738 | public function storagePath ( ) { if ( $ this -> storagePath ) return $ this -> storagePath ; return $ this -> storagePath ? : $ this -> rootPath ( ) . DIRECTORY_SEPARATOR . 'storage' ; } | Get the path to the application configuration files . |
15,739 | public function createCsrfField ( ) { $ fieldName = Config :: get ( 'security.csrf.field_name' ) ; $ input = new Input ( $ this -> form -> expression ( 'input' ) , [ 'name' => $ fieldName , 'value' => $ this -> createToken ( ) , 'type' => 'hidden' ] ) ; return $ input -> execute ( ) ; } | create csrf token field |
15,740 | public function process ( string $ string , int $ strategy = EnumMacroProcessStorategy :: STRATEGY_LAST ) { $ ret = $ string ; $ replace_exists = false ; $ keyword_list = self :: findMacroKeywords ( $ ret ) ; foreach ( $ keyword_list as $ keyword ) { $ replace = $ this -> callHandlers ( $ keyword , $ strategy ) ; if ( ... | Expand string by macro keyword |
15,741 | private function checkIfReplaceIncludeMacro ( string $ replace ) : bool { $ keyword_list = self :: findMacroKeywords ( $ replace ) ; foreach ( $ keyword_list as $ keyword ) { $ replace = $ this -> callHandlers ( $ keyword , EnumMacroProcessStorategy :: STRATEGY_FISRT ) ; if ( $ replace !== null ) { return true ; } } re... | Check if replace string has macro |
15,742 | private function callHandlers ( string $ keyword , int $ strategy ) { if ( $ this -> handlers ) { $ stack = null ; foreach ( $ this -> handlers as $ handler ) { $ replace = $ handler ( $ keyword ) ; if ( ! is_null ( $ replace ) ) { if ( $ strategy === EnumMacroProcessStorategy :: STRATEGY_FISRT ) { return $ replace ; }... | Callback all handlers |
15,743 | public static function initByPath ( $ path , array $ options = [ 'registry' => Recursive :: ALL_INCLUSIVE , ] ) { if ( ! file_exists ( $ path ) || ! is_readable ( $ path ) ) { throw new RuntimeException ( sprintf ( "Cannot open config file \"%s\"" , $ path ) , self :: EX_CANNOT_OPEN_CONFIG ) ; } $ config = \ donbidon \... | Initializes environment by config file path . |
15,744 | public static function initByArray ( array $ config , array $ options = [ 'registry' => Recursive :: ALL_INCLUSIVE , ] ) { if ( ! is_array ( $ config ) ) { throw new InvalidArgumentException ( sprintf ( "Passed argument isn't array (%s)" , gettype ( $ config ) ) , self :: EX_INVALID_ARG ) ; } $ registry = static :: get... | Initializes environment by config array . |
15,745 | public function exists ( $ category ) { $ ds = DIRECTORY_SEPARATOR ; $ path = app_path ( ) . $ ds . 'lablog' . $ ds . $ category ; if ( $ this -> fs -> isDirectory ( $ path ) ) { return true ; } return false ; } | Check if a given category exists or not . |
15,746 | public function getSubCategories ( $ category ) { $ ds = DIRECTORY_SEPARATOR ; $ categoryPath = str_replace ( '/' , $ ds , $ category ) ; $ basePath = app_path ( ) . $ ds . 'lablog' . $ ds ; $ path = $ basePath . $ categoryPath ; if ( ! $ this -> exists ( $ category ) ) { return array ( ) ; } $ categories = $ this -> f... | Get a given categories sub categories . |
15,747 | public function getCategory ( $ category ) { $ ds = DIRECTORY_SEPARATOR ; $ categoryPath = str_replace ( '/' , $ ds , $ category ) ; $ path = app_path ( ) . $ ds . 'lablog' . $ ds . $ categoryPath ; if ( ! $ this -> exists ( $ category ) ) { return ( object ) array ( ) ; } $ categoryExplode = explode ( '/' , $ category... | Get a given category information . |
15,748 | public function create ( $ delim = '#' , $ data = PHP_EOL ) { if ( $ this -> read ( $ delim ) ) { $ this -> update ( $ delim , $ data ) ; } else { file_put_contents ( $ this -> file , PHP_EOL . '# ' . $ delim . PHP_EOL . $ data . PHP_EOL . '# \\' . $ delim . PHP_EOL , FILE_APPEND ) ; } } | Create or update an entry in the . htaccess file |
15,749 | public function read ( $ delim = '#' ) { $ file = file_get_contents ( $ this -> file ) ; $ delim = preg_quote ( $ delim ) ; if ( preg_match ( "/#\s$delim\s(.*?)\s#\s\\\\$delim/s" , $ file , $ matches ) ) { return trim ( $ matches [ 1 ] ) ; } else { return false ; } } | Read entry from . htaccess file |
15,750 | public function update ( $ delim = '#' , $ data = PHP_EOL ) { $ data = str_replace ( array ( '$1' , '$2' , '$3' , '$4' , '$5' ) , array ( '\$1' , '\$2' , '\$3' , '\$4' , '\$5' ) , $ data ) ; $ delim = preg_quote ( $ delim ) ; file_put_contents ( $ this -> file , trim ( preg_replace ( "/#\s$delim\s(.*?)\s#\s\\\\$delim/s... | Update entry in . htaccess file |
15,751 | public function delete ( $ delim = '#' ) { $ file = file_get_contents ( $ this -> file ) ; $ delim = preg_quote ( $ delim ) ; if ( preg_match ( "/#\s$delim\s(.*?)\s#\s\\\\$delim/s" , $ file , $ matches ) ) { file_put_contents ( $ this -> file , str_replace ( PHP_EOL . $ matches [ 0 ] . PHP_EOL , '' , $ file ) ) ; retur... | Delete entry from . htaccess file |
15,752 | protected function _setTokenizer ( $ tokenizer ) { if ( $ tokenizer !== null && ! ( $ tokenizer instanceof TokenizerInterface ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Invalid tokenizer' ) , null , null , $ tokenizer ) ; } $ this -> tokenizer = $ tokenizer ; } | Assigns a tokenizer to this instance . |
15,753 | protected function chooseCMS ( $ availableInputSystems , $ availableOutputSystems ) { $ this -> info ( "\n************************************************" ) ; $ this -> info ( "\n********* CMS Migration Manager ************" ) ; $ this -> info ( "\n************************************************" ) ; $ in = $ thi... | Starts Console Menu Asks User to choose Input and Output CMS returns array with the two integer |
15,754 | protected function getInputAndOutputDisk ( ) { $ validInputPath = FALSE ; $ validOutputPath = FALSE ; while ( ! $ validInputPath ) { $ goBack = FALSE ; $ rootInput = $ this -> choice ( 'Which input disk?' , array_keys ( config ( 'filesystems.disks.cms.migrations' ) ) , 0 ) ; if ( $ rootInput == 'custom_input' ) { while... | Asks User to enter Root - Path of Input and Output CMS |
15,755 | public function load ( $ path , $ data = array ( ) ) { extract ( $ data ) ; $ fullPath = $ this -> transformPath ( $ path ) ; if ( is_file ( $ fullPath ) ) { return include ( $ fullPath ) ; } else { throw new NonexistentFileException ( 'Script not found: ' . $ fullPath ) ; } } | Includes a PHP file and returns any result returned by the file . |
15,756 | public function editAction ( ) { $ params = $ this -> params ( ) ; $ request = $ this -> getRequest ( ) ; $ locator = $ this -> getServiceLocator ( ) ; $ model = $ locator -> get ( 'Grid\Paragraph\Model\Paragraph\Model' ) -> setLocale ( $ this -> getAdminLocale ( ) ) ; $ form = $ locator -> get ( 'Form' ) -> create ( '... | Edit a content |
15,757 | public function cloneAction ( ) { if ( ! $ this -> getPermissionsModel ( ) -> isAllowed ( 'paragraph.content' , 'create' ) ) { $ this -> getResponse ( ) -> setStatusCode ( 403 ) ; return ; } $ params = $ this -> params ( ) ; $ locator = $ this -> getServiceLocator ( ) ; $ model = $ locator -> get ( 'Grid\Paragraph\Mode... | Clone a content |
15,758 | public function deleteAction ( ) { $ params = $ this -> params ( ) ; $ locator = $ this -> getServiceLocator ( ) ; $ model = $ locator -> get ( 'Grid\Paragraph\Model\Paragraph\Model' ) ; $ paragraph = $ model -> find ( $ params -> fromRoute ( 'id' ) ) ; if ( empty ( $ paragraph ) || $ paragraph -> type !== 'content' ) ... | Delete a content |
15,759 | public function description ( $ description = null ) { if ( $ description === null ) { return $ this -> description ; } $ this -> description = $ description ; } | Set or get the description of the migration |
15,760 | public function classname ( $ classname = null ) { if ( $ classname === null ) { return $ this -> classname ; } $ this -> classname = $ classname ; } | Set or get the name of the migration class |
15,761 | public function setDecoratedObject ( $ decorated ) { if ( ! is_object ( $ decorated ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected an object but got an argument of type "%s" instead.' , gettype ( $ decorated ) ) ) ; } $ this -> decoratedObject = $ decorated ; } | Sets the decorated object . |
15,762 | public function parseFtpString ( $ ftpUrl ) { if ( is_null ( $ this -> ftpUsername ) ) { if ( preg_match ( '/^(?:ftp:\/\/)?([^:]+):([^@]+)@(.*)$/' , $ ftpUrl , $ matches ) ) { $ this -> ftpUsername = $ matches [ 1 ] ; $ this -> ftpPassword = $ matches [ 2 ] ; $ this -> ftpDomain = $ matches [ 3 ] ; } else { throw new \... | helper function to set local vars |
15,763 | protected function buildUnion ( $ prefix , array $ settings ) { $ clause = & $ this -> getClause ( 'UNION' ) ; $ flat = $ this -> flatSettings ( $ settings ) ; $ res = '' ; foreach ( $ clause as $ idx => $ field ) { $ parts = [ ] ; $ prefix = $ idx ? $ field [ 1 ] : '' ; $ parts [ ] = $ this -> quoteItem ( $ field [ 0 ... | Build unioned SELECT |
15,764 | public function makeMove ( array $ boardState , $ player = Game :: PLAYER_A ) { $ this -> setBoard ( $ boardState ) ; $ recommendedMove = $ this -> getMove ( $ player ) ? : [ ] ; return $ recommendedMove ? array_merge ( $ recommendedMove , [ $ player ] ) : [ ] ; } | Get move for a particular player |
15,765 | public function registerContainerConfiguration ( LoaderInterface $ loader ) { $ classInfo = new \ ReflectionClass ( $ this ) ; $ dir = dirname ( $ classInfo -> getFileName ( ) ) ; $ loader -> load ( $ dir . '/config.yml' ) ; } | Register container configuration |
15,766 | public static function implementsInterface ( $ class_name , $ interface_name ) { if ( is_object ( $ class_name ) ) { $ class_name = get_class ( $ class_name ) ; } if ( class_exists ( $ class_name ) ) { $ interfaces = class_implements ( $ class_name ) ; return ( bool ) in_array ( $ interface_name , $ interfaces ) || in_... | Check if a class implements a certain interface |
15,767 | public static function extendsClass ( $ class_name , $ mother_name ) { if ( is_object ( $ class_name ) ) { $ class_name = get_class ( $ class_name ) ; } if ( class_exists ( $ class_name ) ) { return ( bool ) is_subclass_of ( $ class_name , $ mother_name ) ; } return false ; } | Check if a class extends a certain class |
15,768 | public static function isClassInstance ( $ object , $ class_name ) { if ( class_exists ( $ class_name ) && is_object ( $ object ) ) { return ( bool ) ( $ object instanceof $ class_name ) ; } return false ; } | Check if a an object is an instance of a class |
15,769 | public static function namespaceExists ( $ namespace ) { $ namespace = trim ( $ namespace , self :: NAMESPACE_SEPARATOR ) ; $ namespace .= self :: NAMESPACE_SEPARATOR ; foreach ( get_declared_classes ( ) as $ name ) { if ( strpos ( $ name , $ namespace ) === 0 ) { return true ; } } if ( class_exists ( $ _composer_loade... | Test if a namespace can be found in declared classes or via Composer autoloader if so |
15,770 | public static function fetchArguments ( $ method_name = null , $ arguments = null , $ class_name = null , & $ logs = array ( ) ) { $ args_def = self :: organizeArguments ( $ method_name , $ arguments , $ class_name , $ logs ) ; if ( ! empty ( $ class_name ) ) { if ( is_callable ( array ( $ class_name , $ method_name ) ... | Launch a function or class s method fetching it arguments according to its declaration |
15,771 | public function get_physical_table_name ( $ table_name ) { $ prefix = $ this -> conf ( ) -> prefix ; if ( strlen ( $ prefix ) ) { $ prefix = preg_replace ( '/\_*$/' , '_' , $ prefix ) ; } return $ prefix . $ table_name ; } | getting table prefix |
15,772 | public static function parse ( $ object ) { $ len = \ strlen ( $ object ) ; if ( Number :: between ( $ len , MySQL :: getConstant ( 'CHAR_LEN_MIN' ) , MySQL :: getConstant ( 'CHAR_LEN_MAX' ) ) ) { return new static ( $ len , static :: CHAR ) ; } else if ( Number :: between ( $ len , MySQL :: getConstant ( 'VARCHAR_LEN_... | Parse a string object to a MySQL string type Prefers VARCHARs over BLOBs |
15,773 | public function getRouteCollectionForRequest ( Request $ request ) { $ slug = '/' . trim ( $ request -> getPathInfo ( ) , '/' ) ; $ document = $ this -> repository -> findOneBy ( array ( 'slug' => $ slug ) ) ; $ collection = new RouteCollection ( ) ; if ( $ document ) { $ controller = $ this -> templateControllers [ $ ... | Finds routes that may potentially match the request . |
15,774 | protected function catchException ( \ Exception $ e ) { foreach ( $ this -> onException as $ call ) { call_user_func_array ( $ call , [ $ e ] ) ; } throw $ e ; } | Catch tick exception and throw it . |
15,775 | public function load ( $ filename ) { if ( ! file_exists ( $ filename ) ) { throw new \ Exception ( 'Ini file "' . $ filename . '" doesn\'t exist.' ) ; return false ; } $ this -> filename = $ filename ; return $ this ; } | Load INI file |
15,776 | public function pushEvent ( string $ name , $ data = null ) : Event { $ event = new Event ( $ name , $ data ) ; $ this -> queue -> enqueue ( $ event ) ; return $ event ; } | Add an event to event queue |
15,777 | protected function addHandler ( TypedHandler $ handler ) { $ this -> addHandlerTypes ( $ handler ) ; $ this -> handlers [ ] = $ handler ; return $ this ; } | Add a handler to the adapter . The handler s supported types will be added to the adapter s supported types . |
15,778 | protected function assignToHandlers ( array $ objects ) { $ result = [ ] ; $ perType = TypedUtils :: groupByType ( $ objects ) ; foreach ( $ this -> handlers as $ handler ) { $ remainingTypes = array_keys ( $ perType ) ; $ handlerTypes = $ handler -> getSupportedEntityTypes ( ) ; $ useTypes = $ handlerTypes === null ? ... | Assign every entity to the first handler that supports it |
15,779 | protected function checkUnsupportedTypes ( array $ objects ) { if ( $ this -> supportedTypes !== null ) { $ unsupportedTypes = array_diff ( TypedUtils :: uniqueTypes ( $ objects ) , $ this -> supportedTypes ) ; if ( count ( $ unsupportedTypes ) > 0 ) { throw new Exception ( sprintf ( 'Encountered unsupported types %s (... | Validate that all the entity types from a request are supported by this adapter |
15,780 | final public function table ( $ table , $ getData = false , $ dataType = null ) { if ( ! empty ( $ table ) ) { $ this -> from ( $ table ) ; } return $ this ; } | Specifies the table upon which a read or write query is performed |
15,781 | final public function traceTableAlias ( $ table ) { if ( is_array ( $ table ) ) { foreach ( $ table as $ t ) { $ this -> traceTableAlias ( $ t ) ; } return ; } if ( strpos ( $ table , ',' ) !== FALSE ) { return $ this -> traceTableAlias ( explode ( ',' , $ table ) ) ; } if ( strpos ( $ table , " " ) !== FALSE ) { $ tab... | This method allows us to preserve and track table aliasis as we build the query statement |
15,782 | final public function identifiers ( $ identifier ) { $ identifier = preg_replace ( '/[\t ]+/' , ' ' , $ identifier ) ; $ alias = '' ; if ( strpos ( $ identifier , ' ' ) !== FALSE ) { $ alias = strstr ( $ identifier , " " ) ; $ identifier = substr ( $ identifier , 0 , - strlen ( $ alias ) ) ; } if ( strpos ( $ identifie... | Helper method for modifying any indentifiers in the query |
15,783 | final public function orderBy ( $ orderby , $ direction = '' ) { if ( strtolower ( $ direction ) == 'random' ) { $ orderby = '' ; $ direction = $ this -> _randomKeyword ; } elseif ( trim ( $ direction ) != '' ) { $ direction = ( in_array ( strtoupper ( trim ( $ direction ) ) , array ( 'ASC' , 'DESC' ) , TRUE ) ) ? ' ' ... | Adds the ORDER BY clause to the query statement |
15,784 | final public function count ( $ table = '' , $ resetselect = true ) { if ( ! empty ( $ table ) ) { $ this -> traceTableAlias ( $ table ) ; $ this -> fromTable ( $ table ) ; } $ sql = $ this -> compile ( $ this -> _countString . $ this -> identifiers ( 'totalcount' ) , true ) ; $ statement = $ this -> DBO -> prepare ( $... | Counts all the records in the specified table Or records which satisfy the compiled SQL statement |
15,785 | final public function where ( $ key , $ value = NULL , $ type = 'AND' , $ escape = TRUE ) { if ( empty ( $ key ) ) { return $ this ; } if ( ! is_array ( $ key ) ) { if ( is_null ( $ value ) ) { return $ this ; } $ key = array ( $ key => $ value ) ; } foreach ( $ key as $ k => $ v ) { $ prefix = ( count ( $ this -> arra... | Adds a WHERE condition to the Query statement . NOTE to change the operatory append the desired operator to the key names for example use |
15,786 | final public function hasOperator ( $ string ) { $ string = trim ( $ string ) ; $ matches = array ( ) ; if ( ! preg_match ( "/(\<|>|!|=|is null|BETWEEN|is not null)/i" , $ string , $ matches ) ) { return FALSE ; } return TRUE ; } | Searches for a standard MySQL operator in a specified string |
15,787 | final public function join ( $ table , $ cond , $ type = 'LEFT' ) { if ( $ type != '' ) { $ type = strtoupper ( trim ( $ type ) ) ; if ( ! in_array ( $ type , array ( 'LEFT' , 'RIGHT' , 'OUTER' , 'INNER' , 'LEFT OUTER' , 'RIGHT OUTER' ) ) ) { $ type = '' ; } else { $ type .= ' ' ; } } $ this -> traceTableAlias ( $ tabl... | Adds a JOIN query statement |
15,788 | final public function getWhere ( $ key , $ values = NULL , $ type = 'AND' ) { return $ this -> where ( $ key , $ values , $ type ) ; } | Returns the result set from a compiled Query representing the where conditions . |
15,789 | final public function notIn ( $ key , $ values ) { if ( empty ( $ key ) || empty ( $ values ) ) { return $ this ; } if ( ! is_array ( $ values ) ) { $ values = array ( $ values ) ; } return $ this -> in ( $ key , $ values , TRUE ) ; } | adds a NOT IN clause to the statement |
15,790 | final public function like ( $ field , $ match = '' , $ type = 'AND ' , $ side = 'both' , $ not = '' ) { if ( ! is_array ( $ field ) ) { $ field = array ( $ field => $ match ) ; } foreach ( $ field as $ k => $ v ) { $ k = $ this -> identifiers ( $ k ) ; $ prefix = ( count ( $ this -> arrayLike ) == 0 ) ? '' : $ type ; ... | Adds a LIKE cluase to the query statement |
15,791 | final public function notLike ( $ field , $ match = '' , $ type = 'AND' , $ side = 'both' ) { return $ this -> like ( $ field , $ match , $ type , $ side , 'NOT' ) ; } | Adds a NOT LIKE to the statement |
15,792 | final public function groupBy ( $ by ) { if ( is_string ( $ by ) ) { $ by = explode ( ',' , $ by ) ; } foreach ( $ by as $ val ) { $ val = trim ( $ val ) ; if ( $ val != '' ) { $ this -> arrayGroupBy [ ] = $ this -> identifiers ( $ val ) ; if ( $ this -> arrayCaching === TRUE ) { $ this -> arrayCacheGroupBy [ ] = $ thi... | Adds a group by clause to a query statement |
15,793 | final public function distinct ( $ boolean = TRUE ) { $ this -> arrayDistinct = ( is_bool ( $ boolean ) ) ? $ boolean : TRUE ; return $ this ; } | Adds a distinct clause to a select query statement |
15,794 | final public function having ( $ key , $ value = '' , $ type = 'AND ' , $ escape = TRUE ) { if ( ! is_array ( $ key ) ) { $ key = array ( $ key => $ value ) ; } foreach ( $ key as $ k => $ v ) { $ prefix = ( count ( $ this -> arrayHaving ) == 0 ) ? '' : $ type ; if ( $ escape === TRUE ) { $ k = $ this -> identifiers ( ... | Adds a having clause to a query statement |
15,795 | final public function limit ( $ value , $ offset = '' ) { $ this -> arrayLimit = $ value ; if ( $ offset != '' ) { $ this -> arrayOffset = $ offset ; } return $ this ; } | Adds a limit to the query statement |
15,796 | final public function prepare ( ) { $ DB = $ this -> DBO ; $ QUERY = $ this -> compile ( ) ; $ STATEMENT = $ DB -> prepare ( $ QUERY ) ; return $ STATEMENT ; } | Runs a compiled Statement i . e prepare |
15,797 | public function complexAttrib ( $ name , $ value , $ delimiter = ' ' , $ check = false ) { $ this -> attributes -> setComplexAttrib ( $ name , $ value , $ delimiter , $ check ) ; return $ this ; } | Sets or appends to a composable attribute . |
15,798 | public function booleanAttrib ( $ name , $ value = true , $ comparisonAttribute = null ) { $ this -> attributes -> setBooleanAttrib ( $ name , $ value , $ comparisonAttribute ) ; return $ this ; } | Sets a boolean attribute if applicable by comparing a value with the value of another attribute . |
15,799 | public static function fromXml ( \ DOMNodeList $ xml ) { $ items = array ( ) ; foreach ( $ xml as $ xmlTag ) { $ items [ ] = StringLiteral :: create ( $ xmlTag -> textContent ) ; } return new static ( $ items ) ; } | Builds a Collection object from XML . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.