idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
237,900 | public function addRule ( $ name , $ args ) { $ this -> options [ 'rules' ] [ $ this -> lastKey ] [ $ name ] = $ args ; $ this -> lastRule = $ name ; return $ this ; } | Add rule for current field |
237,901 | protected function getForeignKeysQuery ( $ value ) { $ flt = [ 'TABLE_SCHEMA' => $ value [ 'REFERENCED_TABLE_SCHEMA' ] , 'TABLE_NAME' => $ value [ 'REFERENCED_TABLE_NAME' ] , 'DATA_TYPE' => [ 'char' , 'varchar' , 'text' ] , ] ; if ( array_key_exists ( 'LIMIT' , $ value ) ) { $ flt [ 'LIMIT' ] = $ value [ 'LIMIT' ] ; } ... | prepares the query to detect FKs |
237,902 | private function sManageDynamicFilters ( $ filterArray = null , $ tableToApplyFilterTo = '' ) { if ( is_null ( $ filterArray ) ) { return '' ; } $ fltr = [ ] ; unset ( $ filterArray [ 'LIMIT' ] ) ; foreach ( $ filterArray as $ key => $ value ) { $ fltr [ ] = '`' . $ tableToApplyFilterTo . '`.`' . $ key . '` ' . $ this ... | Internal function to manage the filters passed to the query |
237,903 | private function setArrayLineArrayToFilter ( $ key , $ value , $ referenceTable ) { $ filters2 = implode ( ', ' , array_diff ( $ value , [ '' ] ) ) ; if ( $ filters2 != '' ) { return '(' . $ referenceTable . '`' . $ key . '` IN ("' . str_replace ( ',' , '","' , str_replace ( [ "'" , '"' ] , '' , $ filters2 ) ) . '"))' ... | Builds an filter string from pair of key and value where value is array |
237,904 | private function setArrayLineToFilter ( $ key , $ value ) { $ fTemp = '=' ; if ( ( substr ( $ value , 0 , 1 ) == '%' ) && ( substr ( $ value , - 1 ) == '%' ) ) { $ fTemp = 'LIKE' ; } return '(`' . $ key . '` ' . $ fTemp . '"' . $ value . '")' ; } | Builds an filter string from pair of key and value none array |
237,905 | public function installedAction ( Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( 'AnimeDbAppBundle:Plugin' ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ rep = $ this -> getDoctrine ( ) -> getRepository ( 'AnimeDbAppBundle:Plugin' ) ; return $ this -... | Installed plugins . |
237,906 | public function storeAction ( Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( [ ] , self :: CACHE_LIFETIME ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ plugins = [ ] ; $ data = $ this -> get ( 'anime_db.api.client' ) -> getPlugins ( ) ; foreach ( $ ... | Store of plugins . |
237,907 | public function getIterator ( ) { if ( $ this -> shared ) { foreach ( $ this -> bindings as $ key => $ binding ) { if ( empty ( $ this -> bound [ $ key ] ) ) { $ this -> bound [ $ key ] = $ this -> container -> getBound ( $ binding ) ; } } return new \ ArrayIterator ( $ this -> bound ) ; } $ bound = [ ] ; foreach ( $ t... | Provides an iterator on top of all registered services obtaining the iterator triggers loading of ALL registered services from the DI container . |
237,908 | public function registerService ( BindingInterface $ binding , $ name = NULL ) { $ key = ( $ name === NULL ) ? $ binding -> getTypeName ( ) : ( string ) $ name ; if ( isset ( $ this -> bindings [ $ key ] ) ) { throw new DuplicateServiceRegistrationException ( sprintf ( 'Service "%s" is already registered' , $ key ) ) ;... | Register a binding in the locator will use the name of the bound type when no name for the service is given . |
237,909 | public function getPhoto ( $ photoId , $ size = 'large' ) { $ photo = Photo :: findOrFail ( $ photoId ) ; switch ( $ size ) { case 'large' : return response ( ) -> download ( storage_path ( ) . '/app/' . $ photo -> pathLarge ) ; case 'small' : return response ( ) -> download ( storage_path ( ) . '/app/' . $ photo -> pa... | Return a photo as a response . |
237,910 | public function getLength ( ) { if ( ! $ this -> container ) { return 0 ; } $ count = count ( $ this -> container ) ; $ keys = array_keys ( $ this -> container ) ; return ( array_keys ( $ this -> container ) === range ( 0 , $ count - 1 ) ) ? $ count : max ( $ keys ) ; } | Copying JS - like . length behavior |
237,911 | public function crudShow ( Request $ request , $ id ) { try { $ entity = $ this -> throwEntityNotFoundException ( $ this -> getRepository ( ) -> find ( $ id ) ) ; $ form = $ this -> createDeleteForm ( $ id ) -> createView ( ) ; return $ this -> commonsResponseVars ( compact ( 'entity' , 'form' ) ) ; } catch ( \ Excepti... | Finds and displays an entity . |
237,912 | public function crudUpdate ( Request $ request , $ id ) { try { $ entity = $ this -> throwEntityNotFoundException ( $ this -> getRepository ( ) -> find ( $ id ) ) ; $ form = $ this -> createForm ( $ this -> getEntityType ( ) , $ entity ) ; $ form -> submit ( $ request ) ; $ page = static :: EDIT_VIEW ; if ( $ form -> i... | Edits an existing entity . |
237,913 | public static function translate ( \ Exception $ e ) : \ Exception { if ( $ e instanceof \ MongoDB \ Driver \ Exception \ ConnectionException || $ e instanceof \ MongoDB \ Driver \ Exception \ ExecutionTimeoutException ) { return new \ Caridea \ Dao \ Exception \ Unreachable ( "System unreachable or connection timed ou... | Translates a MongoDB exception . |
237,914 | public function overwrite ( $ key , $ message = null ) { if ( ! is_array ( $ key ) ) { $ this -> overwrites [ $ key ] = $ message ; return $ this ; } foreach ( $ key as $ k => $ v ) { $ this -> overwrite ( $ k , $ v ) ; } return $ this ; } | Overwrite one or more lang keys |
237,915 | protected function findModelByUUID ( $ uuid ) { if ( ( $ model = Article :: findOne ( [ 'uuid' => $ uuid ] ) ) != null ) { return $ model ; } throw new NotFoundHttpException ( Yii :: t ( 'yii' , 'The requested page does not exist' ) ) ; } | Finds the Article model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown . |
237,916 | public function get ( $ hash = null ) { $ hash = $ hash ? : $ this -> app -> request -> token ( ) ; $ path = $ this -> path ( $ hash ) ; if ( ! file_exists ( $ path ) ) { return false ; } touch ( $ path ) ; $ data = json_decode ( file_get_contents ( $ path ) , true ) ; return $ data ; } | Gets the token data |
237,917 | public function create ( $ data = [ ] ) { $ hash = $ this -> hash ( ) ; $ data = array_merge ( $ data , [ 'token' => $ hash , 'timestamp' => time ( ) ] ) ; $ stored = file_put_contents ( $ this -> path ( $ hash ) , json_encode ( $ data ) ) ; return ( $ stored ) ? $ data : false ; } | Creates a token |
237,918 | public function update ( $ hash = null , $ data ) { $ hash = $ hash ? : $ this -> app -> request -> token ( ) ; $ token = $ this -> get ( $ hash ) ; $ data = array_merge_recursive ( $ token , $ data ) ; $ stored = file_put_contents ( $ this -> path ( $ hash ) , json_encode ( $ data ) ) ; return ( $ stored ) ? $ data : ... | Updates a token |
237,919 | public function destroy ( $ hash = null ) { $ hash = $ hash ? : $ this -> app -> request -> token ( ) ; $ path = $ this -> path ( $ hash ) ; if ( ! file_exists ( $ path ) ) { return true ; } $ success = unlink ( $ path ) ; if ( ! $ success ) { throw new Exception ( "The session could not be erased" , 500 ) ; } return $... | Destroys a token |
237,920 | private function prepare ( $ route ) { $ this -> route = $ route ; $ this -> setBeforeFilter ( $ route -> before ( ) ) ; $ this -> setAfterRelease ( $ route -> after ( ) ) ; } | prepares before filters and after releases from route . |
237,921 | function fallbackRule ( ) { if ( ! isset ( $ this -> fallback_rule ) ) { foreach ( $ this -> rules as $ key => $ rule ) { if ( $ rule -> isFallback ( ) ) { $ this -> fallback_rule = $ rule ; } } } return $ this -> fallback_rule ; } | Fallback rule usually has a key of other but that may not be necessary in all cases . |
237,922 | public function get ( $ handlerServiceId ) { $ handler = $ this -> container -> get ( $ handlerServiceId ) ; if ( ! $ handler instanceof CommandHandlerInterface ) { throw new \ InvalidArgumentException ( 'Handler must be instance if ' . CommandHandlerInterface :: class ) ; } return $ handler ; } | Get command handler |
237,923 | protected static function engine ( ) { $ engine = '' ; foreach ( static :: $ engines as $ name => $ function ) { if ( $ function === null || function_exists ( $ function ) ) { $ engine = $ name ; break ; } } return $ engine ; } | Get name of php Cache engine used . |
237,924 | public static function build ( $ engine = null , $ namespace = '\Eureka\Component\Cache' ) { if ( null === $ engine ) { $ engine = static :: engine ( ) ; } if ( empty ( static :: $ instances [ $ engine ] ) ) { $ class = $ namespace . '\\' . 'CacheWrapper' . $ engine ; static :: $ instances [ $ engine ] = new $ class ( ... | Instantiate Cache Wrapper object & return it . |
237,925 | public static function translate ( $ key , $ params = [ ] , $ language = null , Viewmodel $ viewmodel = null ) { $ identifier = null ; if ( null !== $ viewmodel ) { $ identifier = static :: load ( $ viewmodel ) ; } if ( null === $ key ) { $ key = '' ; } if ( false === is_string ( $ key ) ) { return trigger_error ( spri... | Translate text based on a key |
237,926 | public static function load ( $ source ) { if ( false === is_string ( $ source ) && false === $ source instanceof Viewmodel ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or instance of sFire\MVC\Viewmodel, "%s" given' , __METHOD__ , gettype ( $ source ) ) , E_USER_ERROR ) ; ... | Loads a new translation file |
237,927 | private static function cache ( File $ cache , File $ file ) { if ( false === isset ( static :: $ translations [ $ cache -> entity ( ) -> getName ( ) ] ) ) { $ parse = true ; if ( true === $ cache -> exists ( ) ) { if ( $ cache -> entity ( ) -> getModificationTime ( ) >= $ file -> entity ( ) -> getModificationTime ( ) ... | Returns cache if exists otherwise the translation cache file is created filled with content and returned |
237,928 | private static function parse ( File $ file ) { $ lines = explode ( "\n" , $ file -> getContent ( ) ) ; $ languages = [ ] ; foreach ( $ lines as $ index => $ line ) { $ line = trim ( $ line ) ; if ( '' === $ line ) { continue ; } preg_match ( '#^\[([a-z_\-0-9]+)\]#i' , $ line , $ language ) ; if ( count ( $ language ) ... | Parses a translation file and converts it into an array |
237,929 | public function check ( array $ scripts , array $ rollbacks ) { $ this -> checkScripts ( $ scripts , $ rollbacks ) ; foreach ( $ scripts as $ k => $ script ) { $ this -> checkScript ( $ script , $ rollbacks [ $ k ] ) ; } } | Check a release scripts & rollbacks and each script separately |
237,930 | public function get ( $ key ) { if ( isset ( $ this -> settings [ $ key ] ) ) { return $ this -> settings [ $ key ] ; } return null ; } | Get configuration parameter by key if exists else return null |
237,931 | public function cmdGetFieldValue ( ) { $ result = $ this -> getListFieldValue ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableFieldValue ( $ result ) ; $ this -> output ( ) ; } | Callback for field - value - get command |
237,932 | public function cmdDeleteFieldValue ( ) { $ id = $ this -> getParam ( 0 ) ; if ( empty ( $ id ) || ! is_numeric ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( $ this -> getParam ( 'field' ) ) { $ deleted = $ count = 0 ; foreach ( $ this -> field_value -> getList ( array ( 'field_i... | Callback for field - value - delete command |
237,933 | public function cmdUpdateFieldValue ( ) { $ 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 field - value - update command |
237,934 | protected function getListFieldValue ( ) { $ id = $ this -> getParam ( 0 ) ; if ( ! isset ( $ id ) ) { return $ this -> field_value -> getList ( array ( 'limit' => $ this -> getLimit ( ) ) ) ; } if ( $ this -> getParam ( 'field' ) ) { return $ this -> field_value -> getList ( array ( 'field_id' => $ id , 'limit' => $ t... | Returns an array of field values |
237,935 | protected function addFieldValue ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> field_value -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } } | Add a new field value |
237,936 | protected function submitAddFieldValue ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'field_value' ) ; $ this -> addFieldValue ( ) ; } | Add a new field value at once |
237,937 | protected function wizardAddFieldValue ( ) { $ this -> validatePrompt ( 'title' , $ this -> text ( 'Title' ) , 'field_value' ) ; $ this -> validatePrompt ( 'field_id' , $ this -> text ( 'Field ID' ) , 'field_value' ) ; $ this -> validatePrompt ( 'color' , $ this -> text ( 'Color' ) , 'field_value' , '' ) ; $ this -> va... | Add a new field value step by step |
237,938 | protected function _stringableJoin ( $ parts , $ delim ) { $ parts = $ this -> _normalizeIterable ( $ parts ) ; $ i = 0 ; $ result = '' ; foreach ( $ parts as $ _part ) { try { $ _part = $ this -> _normalizeString ( $ _part ) ; } catch ( InvalidArgumentException $ e ) { throw $ this -> _createOutOfRangeException ( $ th... | Joins a list of parts using a delimiter . |
237,939 | public static function reorder ( array $ data , array $ order , $ throwExceptionIfKeyNotFound = false , $ throwExceptionIfExtraData = false ) { $ result = array ( ) ; foreach ( $ order as $ orderedKey ) { if ( array_key_exists ( $ orderedKey , $ data ) ) { $ result [ $ orderedKey ] = $ data [ $ orderedKey ] ; unset ( $... | Orders data based on order of values in order array |
237,940 | public function init ( $ config = NULL ) { parent :: init ( $ config ) ; if ( isset ( $ config [ 'id' ] ) ) { $ this -> id = ( int ) $ config [ 'id' ] ; } $ this -> doAction ( self :: ON_MODEL_INIT_ACTION ) ; } | Initialises the model . |
237,941 | public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Config' ) ; $ navigationConfig = $ config [ 'navigation' ] ; $ navigation = new Navigation ( $ navigationConfig ) ; return $ navigation ; } | Create navigation service |
237,942 | public function getProperty ( ) { return ' /** * @var ' . $ this -> getType ( ) -> getType ( ) . ' $' . $ this -> getPropertyName ( ) . ' */ protected $' . $ this -> getPropertyName ( ) . ' = ' . $ this -> getDefault ( true ) . ';' ; } | Get property declaration . |
237,943 | public function getGetter ( ) { return ' /** * Get value for field "' . $ this -> getName ( ) . '" * * @return ' . $ this -> getType ( ) -> getType ( ) . ' */ public function ' . $ this -> getMethodNameGet ( ) . '() { return $this->' . $ this -> getPropertyName ( ) . '; }' ; } | Get method getter . |
237,944 | public function getSetter ( ) { $ varname = '$' . $ this -> getPropertyName ( ) ; $ autoinc = '' ; $ cast = $ this -> getType ( ) -> getCastMethod ( ) . ' ' ; if ( $ this -> isNullable ( ) ) { $ forceCast = $ varname . ' = (' . $ varname . ' === null ? ' . $ varname . ' : ' . $ cast . $ varname . ');' ; } else { $ forc... | Get method setter . |
237,945 | public function getName ( $ withoutPrefix = false ) { $ name = $ this -> name ; if ( $ withoutPrefix && stripos ( $ name , $ this -> dbPrefix ) === 0 ) { $ name = substr ( $ name , strlen ( $ this -> dbPrefix ) ) ; } return $ name ; } | Get name . Can remove table prefix . |
237,946 | protected function setData ( \ stdClass $ column ) { $ this -> setName ( $ column -> Field ) ; $ this -> setIsPrimaryKey ( ( $ column -> Key === 'PRI' ) ) ; $ this -> setIsKey ( ! empty ( $ column -> Key ) ) ; $ this -> setType ( $ column -> Type ) ; $ this -> setIsNullable ( ( $ column -> Null === 'YES' ) ) ; $ this -... | Set column data from db query |
237,947 | public function getMethodNameGet ( ) { $ methodName = str_replace ( ' ' , '' , ucwords ( str_replace ( array ( '_is_' , '_has_' , '_in_' , '_' , ) , ' ' , strtolower ( $ this -> getName ( true ) ) ) ) ) ; $ type = $ this -> getType ( ) ; switch ( true ) { case ( $ type instanceof Type \ TypeBool ) && stripos ( $ this -... | Get method name for getter . |
237,948 | protected function setExtra ( $ extra ) { if ( empty ( $ extra ) ) { return $ this ; } switch ( $ extra ) { case 'auto_increment' : $ this -> isAutoIncrement = true ; break ; } return $ this ; } | Set extra info . |
237,949 | protected function getCheck ( ) { $ check = array ( 0 => '' , 1 => '' ) ; $ type = $ this -> getType ( ) ; switch ( $ type -> getType ( ) ) { case 'int' : case 'float' : if ( $ type -> isUnsigned ( ) ) { $ check [ 1 ] = '\UnderflowException' ; $ check [ 0 ] = ' if ($this->' . $ this -> getPropertyName ( ) . ' < ... | Get check condition for numeric values & underflow if necessary . |
237,950 | public function run ( $ url = null , $ method = null ) { $ route = $ this -> altoRouter -> match ( $ url , $ method ) ; if ( ! $ route ) { throw new NotFoundException ( ( ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) && ! empty ( $ _SERVER [ 'REQUEST_URI' ] ) ) ? $ _SERVER [ 'REQUEST_URI' ] : ( ( $ url != null ) ? $ url : "/... | This function runs the router and call the apropriate |
237,951 | public function filterByFiles ( $ files = null , $ comparison = null ) { if ( is_array ( $ files ) ) { $ useMinMax = false ; if ( isset ( $ files [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_FILES , $ files [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ files [ 'max... | Filter the query on the files column |
237,952 | public function filterBySubcats ( $ subcats = null , $ comparison = null ) { if ( is_array ( $ subcats ) ) { $ useMinMax = false ; if ( isset ( $ subcats [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_SUBCATS , $ subcats [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ ... | Filter the query on the subcats column |
237,953 | public function filterBySize ( $ size = null , $ comparison = null ) { if ( is_array ( $ size ) ) { $ useMinMax = false ; if ( isset ( $ size [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_SIZE , $ size [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ size [ 'max' ] ) )... | Filter the query on the size column |
237,954 | public function filterByHidden ( $ hidden = null , $ comparison = null ) { if ( is_string ( $ hidden ) ) { $ hidden = in_array ( strtolower ( $ hidden ) , array ( 'false' , 'off' , '-' , 'no' , 'n' , '0' , '' ) ) ? false : true ; } return $ this -> addUsingAlias ( CategoryTableMap :: COL_HIDDEN , $ hidden , $ compariso... | Filter the query on the hidden column |
237,955 | public function filterByTreeLeft ( $ treeLeft = null , $ comparison = null ) { if ( is_array ( $ treeLeft ) ) { $ useMinMax = false ; if ( isset ( $ treeLeft [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_TREE_LEFT , $ treeLeft [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( iss... | Filter the query on the tree_left column |
237,956 | public function filterByTreeRight ( $ treeRight = null , $ comparison = null ) { if ( is_array ( $ treeRight ) ) { $ useMinMax = false ; if ( isset ( $ treeRight [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_TREE_RIGHT , $ treeRight [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if... | Filter the query on the tree_right column |
237,957 | public function filterByTreeLevel ( $ treeLevel = null , $ comparison = null ) { if ( is_array ( $ treeLevel ) ) { $ useMinMax = false ; if ( isset ( $ treeLevel [ 'min' ] ) ) { $ this -> addUsingAlias ( CategoryTableMap :: COL_TREE_LEVEL , $ treeLevel [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if... | Filter the query on the tree_level column |
237,958 | public function filterBySource ( $ source , $ comparison = null ) { if ( $ source instanceof \ Attogram \ SharedMedia \ Orm \ Source ) { return $ this -> addUsingAlias ( CategoryTableMap :: COL_SOURCE_ID , $ source -> getId ( ) , $ comparison ) ; } elseif ( $ source instanceof ObjectCollection ) { if ( null === $ compa... | Filter the query by a related \ Attogram \ SharedMedia \ Orm \ Source object |
237,959 | public function filterByC2M ( $ c2M , $ comparison = null ) { if ( $ c2M instanceof \ Attogram \ SharedMedia \ Orm \ C2M ) { return $ this -> addUsingAlias ( CategoryTableMap :: COL_ID , $ c2M -> getCategoryId ( ) , $ comparison ) ; } elseif ( $ c2M instanceof ObjectCollection ) { return $ this -> useC2MQuery ( ) -> fi... | Filter the query by a related \ Attogram \ SharedMedia \ Orm \ C2M object |
237,960 | public function descendantsOf ( ChildCategory $ category ) { return $ this -> addUsingAlias ( ChildCategory :: LEFT_COL , $ category -> getLeftValue ( ) , Criteria :: GREATER_THAN ) -> addUsingAlias ( ChildCategory :: LEFT_COL , $ category -> getRightValue ( ) , Criteria :: LESS_THAN ) ; } | Filter the query to restrict the result to descendants of an object |
237,961 | public function childrenOf ( ChildCategory $ category ) { return $ this -> descendantsOf ( $ category ) -> addUsingAlias ( ChildCategory :: LEVEL_COL , $ category -> getLevel ( ) + 1 , Criteria :: EQUAL ) ; } | Filter the query to restrict the result to children of an object |
237,962 | public function siblingsOf ( ChildCategory $ category , ConnectionInterface $ con = null ) { if ( $ category -> isRoot ( ) ) { return $ this -> add ( ChildCategory :: LEVEL_COL , '1<>1' , Criteria :: CUSTOM ) ; } else { return $ this -> childrenOf ( $ category -> getParent ( $ con ) ) -> prune ( $ category ) ; } } | Filter the query to restrict the result to siblings of an object . The result does not include the object passed as parameter . |
237,963 | public function ancestorsOf ( ChildCategory $ category ) { return $ this -> addUsingAlias ( ChildCategory :: LEFT_COL , $ category -> getLeftValue ( ) , Criteria :: LESS_THAN ) -> addUsingAlias ( ChildCategory :: RIGHT_COL , $ category -> getRightValue ( ) , Criteria :: GREATER_THAN ) ; } | Filter the query to restrict the result to ancestors of an object |
237,964 | public function orderByBranch ( $ reverse = false ) { if ( $ reverse ) { return $ this -> addDescendingOrderByColumn ( ChildCategory :: LEFT_COL ) ; } else { return $ this -> addAscendingOrderByColumn ( ChildCategory :: LEFT_COL ) ; } } | Order the result by branch i . e . natural tree order |
237,965 | public function orderByLevel ( $ reverse = false ) { if ( $ reverse ) { return $ this -> addDescendingOrderByColumn ( ChildCategory :: LEVEL_COL ) -> addDescendingOrderByColumn ( ChildCategory :: LEFT_COL ) ; } else { return $ this -> addAscendingOrderByColumn ( ChildCategory :: LEVEL_COL ) -> addAscendingOrderByColumn... | Order the result by level the closer to the root first |
237,966 | public function findRoot ( ConnectionInterface $ con = null ) { return $ this -> addUsingAlias ( ChildCategory :: LEFT_COL , 1 , Criteria :: EQUAL ) -> findOne ( $ con ) ; } | Returns the root node for the tree |
237,967 | static public function retrieveRoot ( ConnectionInterface $ con = null ) { $ c = new Criteria ( CategoryTableMap :: DATABASE_NAME ) ; $ c -> add ( ChildCategory :: LEFT_COL , 1 , Criteria :: EQUAL ) ; return ChildCategoryQuery :: create ( null , $ c ) -> findOne ( $ con ) ; } | Returns the root node for a given scope |
237,968 | static public function retrieveTree ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { if ( null === $ criteria ) { $ criteria = new Criteria ( CategoryTableMap :: DATABASE_NAME ) ; } $ criteria -> addAscendingOrderByColumn ( ChildCategory :: LEFT_COL ) ; return ChildCategoryQuery :: create ( null , $ ... | Returns the whole tree node for a given scope |
237,969 | static public function isValid ( ChildCategory $ node = null ) { if ( is_object ( $ node ) && $ node -> getRightValue ( ) > $ node -> getLeftValue ( ) ) { return true ; } else { return false ; } } | Tests if node is valid |
237,970 | static public function updateLoadedNodes ( $ prune = null , ConnectionInterface $ con = null ) { if ( Propel :: isInstancePoolingEnabled ( ) ) { $ keys = array ( ) ; foreach ( CategoryTableMap :: $ instances as $ obj ) { if ( ! $ prune || ! $ prune -> equals ( $ obj ) ) { $ keys [ ] = $ obj -> getPrimaryKey ( ) ; } } i... | Reload all already loaded nodes to sync them with updated db |
237,971 | protected function resizeImage ( $ path , $ width , $ height ) { $ this -> images -> open ( 'Gd' , $ path ) ; $ this -> images -> resize ( $ width , $ height ) ; } | resizes an image |
237,972 | public static function get_colors ( $ type = 'hex' ) { $ cached = self :: $ colorsCached ; if ( isset ( $ cached [ $ type ] ) ) return $ cached [ $ type ] ; $ colors = Config :: inst ( ) -> get ( 'Identity' , 'colors' ) ; if ( $ type == 'rgb' ) { $ rgbColors = [ ] ; foreach ( $ colors as $ name => $ c ) { $ rgbColors [... | Identify colors in either hex or rgb |
237,973 | public static function hex2rgb ( $ hex ) { $ hex = str_replace ( "#" , "" , $ hex ) ; $ r = hexdec ( substr ( $ hex , 0 , 2 ) ) ; $ g = hexdec ( substr ( $ hex , 2 , 2 ) ) ; $ b = hexdec ( substr ( $ hex , 4 , 2 ) ) ; return "$r,$g,$b" ; } | Helper for converting a color to rbg |
237,974 | public function getResourceTypes ( ) { $ types = [ ] ; foreach ( $ this as $ entity ) { $ types [ ] = $ entity -> getType ( ) ; } return array_unique ( $ types ) ; } | Gets a unique list of all entity types assigned to this collection . |
237,975 | public function on_common ( ) { if ( substr ( $ GLOBALS [ 'request' ] -> server ( 'SCRIPT_NAME' ) , - 7 ) === 'app.php' ) { return ; } try { $ this -> request_stack -> push ( $ this -> symfony_request ) ; $ this -> dispatcher -> dispatch ( KernelEvents :: REQUEST , new GetResponseEvent ( $ this -> http_kernel , $ this ... | Emulate the kernel request event |
237,976 | public function on_garbage_collection ( ) { if ( substr ( $ GLOBALS [ 'request' ] -> server ( 'SCRIPT_NAME' ) , - 7 ) === 'app.php' ) { return ; } set_exception_handler ( array ( $ this , 'exception_handler' ) ) ; try { $ response = new Response ( '<html><body></body></html>' ) ; $ this -> dispatcher -> dispatch ( Kern... | Emulate the kernel response event |
237,977 | public function onKernelResponse ( FilterResponseEvent $ event ) { $ result = parent :: onKernelResponse ( $ event ) ; $ content = ob_get_contents ( ) ; if ( $ this -> request_stack -> getCurrentRequest ( ) -> getMethod ( ) === 'POST' && empty ( $ content ) ) { $ event -> stopPropagation ( ) ; } return $ result ; } | Avoid the injection of the toolbar |
237,978 | public function & refScopeStatistic ( $ scope ) { if ( ! isset ( $ this -> statistics [ $ scope ] ) ) $ this -> statistics [ $ scope ] = [ ] ; return $ this -> statistics [ $ scope ] ; } | Return a reference for batch editing . Do not replace the whole variable into non - array value! |
237,979 | public function load ( ) { $ output = [ ] ; $ args = func_get_args ( ) ; foreach ( $ args as $ arg ) { if ( is_array ( $ arg ) ) { $ output = array_merge ( call_user_func_array ( [ $ this , 'load' ] , $ arg ) , $ output ) ; } else { $ this -> loadHandler ( $ arg ) ; $ output [ ] = $ arg ; } } return $ output ; } | Load a collection of assets into the Di container . Provides a whole load of syntatic sugar so you can basically pass this a combination of arrays assets multiple args ... whatever The actual work is done by loadHandler |
237,980 | public function getList ( ) { $ category = $ this -> getCategory ( ) ; $ list = $ this -> getCategoryConfig ( $ category ) ; foreach ( $ list as $ context => $ config ) { $ list [ $ context ] = $ this -> getAll ( $ context ) ; } return $ list ; } | Get All config entries |
237,981 | public function classname ( $ id ) { return isset ( $ this -> classes [ $ id ] ) ? $ this -> classes [ $ id ] : null ; } | Returns the default or configured classname with namespace |
237,982 | function run ( ) { $ request = $ this -> getServerRequest ( ) ; $ response = $ this -> getResponse ( ) ; $ uri = $ request -> getUri ( ) ; $ basepath = $ uri -> getBasePath ( ) ; $ args = explode ( '/' , htmlspecialchars ( $ basepath ) ) ; $ response = $ this -> process ( $ request , $ response , $ args ) ; $ this -> f... | Runs the engine the processes the request |
237,983 | public function setFilePointer ( $ pointer ) { if ( ! is_resource ( $ pointer ) ) throw new InvalidArgumentException ( "Invalid type - not a file resource" ) ; $ this -> pointer = $ pointer ; $ metadata = stream_get_meta_data ( $ this -> pointer ) ; if ( isset ( $ metadata [ "mode" ] ) ) { $ mode = rtrim ( $ metadata [... | Set the file pointer |
237,984 | protected function getResults ( string $ username , ServerRequestInterface $ request ) : \ MongoDB \ Driver \ Cursor { $ q = new \ MongoDB \ Driver \ Query ( array_merge ( $ this -> query , [ ( $ this -> fieldUser ) => $ username ] ) , [ 'projection' => [ ( $ this -> fieldUser ) => true , ( $ this -> fieldPass ) => tru... | Queries the MongoDB collection . |
237,985 | protected function fetchResult ( \ MongoDB \ Driver \ Cursor $ results , string $ username ) : \ stdClass { $ values = $ results -> toArray ( ) ; if ( count ( $ values ) > 1 ) { throw new \ Caridea \ Auth \ Exception \ UsernameAmbiguous ( $ username ) ; } elseif ( count ( $ values ) == 0 ) { throw new \ Caridea \ Auth ... | Fetches a single result from the Mongo Cursor . |
237,986 | public function destroy ( $ sessionId ) { $ sql = 'DELETE from tbl_sessions where SESSION_ID=:SESSID' ; $ delete = $ this -> _db -> prepare ( $ sql ) ; $ delete -> execute ( array ( ':SESSID' => $ sessionId ) ) ; $ this -> _cache -> delete ( $ sessionId ) ; return true ; } | destroy Destroying the session deletes it from the cache as well as the backend database . |
237,987 | public function gc ( $ lifetime ) { $ sql = 'DELETE from tbl_sessions where LAST_ACCESSED < DATE_SUB(NOW(), INTERVAL :LIFETIME SECOND)' ; $ delete = $ this -> _db -> prepare ( $ sql ) ; $ count = $ delete -> execute ( array ( ':LIFETIME' => $ lifetime ) ) ; return true ; } | Garbage collection causes all expired sessions to be deleted . |
237,988 | public function open ( $ savePath , $ sessionName ) { $ sql = 'INSERT INTO tbl_sessions (SESSION_ID, SESSION_DATA) values (:SESSID, :SESSDATA) ON DUPLICATE KEY UPDATE LAST_ACCESSED=NOW()' ; $ stmt = $ this -> _db -> prepare ( $ sql ) ; $ stmt -> execute ( array ( ':SESSID' => session_id ( ) , ':SESSDATA' => '' ) ) ; } | open Opening the session causes an insert into the sessions table . |
237,989 | public static function lockTables ( $ table = NULL , $ blockType = 'WRITE' ) { $ sql = "LOCK TABLES " ; if ( $ table === NULL ) { $ sql .= self :: tableName ( ) . " $blockType" ; } else { $ tmpSql = '' ; foreach ( ( is_array ( $ table ) ? $ table : [ $ table ] ) as $ key => $ value ) { $ tmpSql .= empty ( $ tmpSql ) ? ... | Lock DB tables |
237,990 | public function renderOut ( ) { foreach ( Error :: all ( ) as $ file => $ error ) { foreach ( $ error as $ line ) { $ this -> addMessage ( 'Template error: ' . $ line . '(' . $ file . ')' , 'error' ) ; } } return $ this -> render -> render ( ) ; } | Render debug bar code |
237,991 | public function addException ( $ e ) { if ( $ e instanceof \ Exception ) { try { $ this -> bar -> getCollector ( 'exceptions' ) -> addException ( $ e ) ; } catch ( \ Exception $ ie ) { } } } | Add exception into debug bar and stop execute |
237,992 | public function addMessage ( $ m , $ type = 'info' ) { if ( ! Any :: isStr ( $ m ) || ! Any :: isStr ( $ type ) ) { return ; } $ m = App :: $ Security -> secureHtml ( $ m ) ; try { $ mCollector = $ this -> bar -> getCollector ( 'messages' ) ; if ( method_exists ( $ mCollector , $ type ) ) { $ this -> bar -> getCollecto... | Add message into debug bar |
237,993 | public static function autobox ( $ value ) { if ( is_numeric ( $ value ) ) { if ( strpos ( $ value , '.' ) !== false ) { return ( float ) $ value ; } else { return ( int ) $ value ; } } else if ( is_bool ( $ value ) ) { return ( bool ) $ value ; } else if ( $ value === 'true' || $ value === 'false' ) { return ( $ value... | Autobox a value by type casting it . |
237,994 | public static function isJson ( $ data ) { if ( ! is_string ( $ data ) || empty ( $ data ) ) { return false ; } $ json = @ json_decode ( $ data , true ) ; return ( json_last_error ( ) === JSON_ERROR_NONE && $ json !== null ) ; } | Check to see if data passed is a JSON object . |
237,995 | public static function isSerialized ( $ data ) { if ( ! is_string ( $ data ) || empty ( $ data ) ) { return false ; } return ( @ unserialize ( $ data ) !== false ) ; } | Check to see if data passed has been serialized . |
237,996 | public static function isXml ( $ data ) { if ( ! is_string ( $ data ) || substr ( $ data , 0 , 5 ) !== '<?xml' ) { return false ; } return ( @ simplexml_load_string ( $ data ) instanceof SimpleXMLElement ) ; } | Check to see if data passed is an XML document . |
237,997 | public function route ( ) { $ this -> dashboardRouting ( $ this -> relativeCmsUri ) ; $ this -> logOffRouting ( $ this -> request , $ this -> relativeCmsUri ) ; $ this -> apiRouting ( $ this -> relativeCmsUri ) ; $ this -> documentRouting ( $ this -> userRights , $ this -> relativeCmsUri ) ; $ this -> valuelistsRouting... | Call the different routing methods |
237,998 | public function getTemplate ( TemplatableNodeInterface $ node ) { $ template = $ node -> getTemplate ( ) ; if ( ! $ template ) { $ meta = $ this -> manager -> getClassMetadata ( get_class ( $ node ) ) ; if ( ! empty ( $ this -> templates [ $ meta -> name ] ) && count ( $ this -> templates [ $ meta -> name ] ) > 0 ) $ t... | get the assigned template of the given TemplatableNodeInterface handles the template selection if no template is assigned |
237,999 | protected static function getBundleNameFromEntity ( $ entityNamespace , $ bundles ) { $ dataBaseNamespace = substr ( $ entityNamespace , 0 , strpos ( $ entityNamespace , '\\Entity' ) ) ; foreach ( $ bundles as $ type => $ bundle ) { $ bundleRefClass = new \ ReflectionClass ( $ bundle ) ; if ( $ bundleRefClass -> getNam... | Get the bundle name from an Entity namespace |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.