idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
47,900 | static function DetermineFileType ( $ filename , $ options = array ( ) , & $ preferred_suffix = null ) { $ options += array ( "original_filename" => null , ) ; if ( ! file_exists ( $ filename ) || is_dir ( $ filename ) ) { return null ; } if ( function_exists ( "mime_content_type" ) ) { $ mime_type = mime_content_type ... | Determines the mime type of the file . |
47,901 | static function FindFiles ( $ directory , $ options = array ( ) ) { $ options += array ( "pattern" => null , "invert_pattern" => null , "min_mtime" => null , "max_mtime" => null , "maxdepth" => null ) ; if ( ! preg_match ( '/\/$/' , $ directory ) ) { $ directory = "$directory/" ; } $ pattern = $ options [ "pattern" ] ;... | Find files in the given directory according to a regular pattern and other criteria |
47,902 | public function isCallable ( ) : bool { return is_callable ( [ $ this -> namespace . $ this -> getController ( true ) , $ this -> getAction ( true ) ] ) ; } | Is this route callable? |
47,903 | public function orWhere ( $ first , $ operator = null , $ second = null ) { return $ this -> on ( $ first , $ operator , $ second , 'or' , true ) ; } | Add an or on where clause to the join . |
47,904 | public function findForPassport ( $ identifier ) { return ( new static ( ) ) -> newQuery ( ) -> orWhere ( function ( $ q ) use ( $ identifier ) { return $ q -> orWhere ( 'email' , $ identifier ) -> orWhere ( 'name' , $ identifier ) ; } ) -> where ( 'enabled' , 1 ) -> first ( ) ; } | Retrieve user for passport oauth . |
47,905 | public static function fetch ( $ file ) { $ url = 'http://www.freeformatter.com/mime-types-list.html' ; if ( file_exists ( $ file ) ) { return ; } $ filePointerCsv = fopen ( $ file , 'wb' ) ; $ fileHtml = \ dirname ( __FILE__ , 2 ) . '/resources/mimes.html' ; if ( ! file_exists ( $ fileHtml ) ) { $ contents = file_get_... | Convert HTML page to CSV then create Mime listings . |
47,906 | public static function generate ( $ file ) { $ filePointer = fopen ( $ file , 'rb' ) ; $ names = '' ; $ extensions = '' ; $ header = true ; while ( ( $ row = fgetcsv ( $ filePointer ) ) ) { if ( $ header ) { $ header = false ; continue ; } $ mime = trim ( $ row [ 0 ] ) ; $ name = trim ( addslashes ( $ row [ 1 ] ) ) ; $... | Generate FileMimes class . |
47,907 | public function createEntity ( $ entity , TableNode $ fields ) { $ this -> models -> get ( $ entity ) -> store ( $ fields -> getRowsHash ( ) ) ; } | Creates an entity with specified fields |
47,908 | public function applyFixtures ( TableNode $ fixtures ) { $ fixtures = $ fixtures -> getColumn ( 0 ) ; $ dataSet = new CompositeDataSet ( ) ; foreach ( $ fixtures as $ fixture ) { $ dataSet -> addDataSet ( $ this -> fixtures -> createMySQLXMLDataSet ( $ fixture ) ) ; } $ this -> fixtures -> applyDataSet ( $ dataSet ) ; ... | Populates a fixture into the database . |
47,909 | public function getClassReflections ( $ code ) { $ result = [ ] ; foreach ( $ this -> getClassNames ( $ code ) as $ className ) { $ result [ $ className ] = new \ ReflectionClass ( $ className ) ; } return $ result ; } | returns the classes form an included code . |
47,910 | protected function undelete ( ) { if ( $ this -> saveButtonPushed ( ) ) { $ nodeRef = $ this -> buildCmsNodeRef ( ) ; $ node = $ nodeRef -> generateNode ( ) ; $ location = 'load' ; $ this -> Events -> trigger ( 'NodeCmsController.undelete' . '.' . $ location , $ this -> errors , $ this -> templateVars , $ node ) ; fore... | Provides undelete functionality for Nodes |
47,911 | protected function single ( ) { $ nq = new NodeQuery ( ) ; $ nq -> setLimit ( 1 ) ; $ this -> passthruTemplateVariable ( $ nq , 'Elements.in' ) ; $ this -> passthruTemplateVariable ( $ nq , 'Sites.in' ) ; $ this -> passthruTemplateVariable ( $ nq , 'Meta.select' ) ; $ this -> passthruTemplateVariable ( $ nq , 'OutTags.... | Datasource for returning a single Node |
47,912 | protected function items ( ) { $ dto = new NodeQuery ( ) ; $ this -> buildLimitOffset ( $ dto ) ; $ this -> passthruTemplateVariable ( $ dto , 'Elements.in' ) ; $ this -> passthruTemplateVariable ( $ dto , 'Sites.in' ) ; $ this -> passthruTemplateVariable ( $ dto , 'Slugs.in' ) ; $ this -> passthruTemplateVariable ( $ ... | Datasource for returning all matching Nodes |
47,913 | protected function buildCmsNodeRef ( $ slugKey = 'OriginalSlug' ) { if ( empty ( $ this -> params [ 'Element' ] ) ) throw new Exception ( 'Element parameter is required' ) ; $ nodeElement = $ this -> ElementService -> getBySlug ( $ this -> params [ 'Element' ] ) ; if ( ! is_null ( $ slugKey ) && $ this -> Request -> ge... | Given a slug builds a nodeRef |
47,914 | public function date ( $ date = null ) { if ( is_null ( $ date ) ) { $ date = $ this -> created_at ; } return String :: date ( $ date ) ; } | Get the date the post was created . |
47,915 | public function parse ( QuoteInterface $ quoting ) { $ outputSql = "" ; foreach ( $ this -> relations as $ relation ) { $ columns = array ( ) ; foreach ( $ relation -> getPrimaryKeys ( ) as $ column ) { $ columns [ $ column -> get ( 'name' ) ] = $ column -> getType ( ) -> getTypeQuery ( ) ; } if ( $ this -> notificatio... | Generate and execute sql which will attach notification triggers to relations |
47,916 | public function donovan ( QuoteInterface $ quoting , $ prefix , $ columns ) { $ sql = array ( ) ; foreach ( $ columns as $ column => $ type ) { $ sql [ ] = sprintf ( 'donovan(%s%s)' , $ prefix , $ quoting -> quoteIdent ( $ column ) ) ; } return sprintf ( "'['||%s||']'" , implode ( "||','||" , $ sql ) ) ; } | Produce a sql statement which resolves to a string but is a valid json |
47,917 | private function catalogRefresh ( ) { Relation :: r ( ) -> preload ( ) ; Attribute :: r ( ) -> preload ( ) ; Type :: r ( ) -> preload ( ) ; Index :: r ( ) -> preload ( ) ; } | Refresh the catalog |
47,918 | public function validate ( Request $ request , array $ rules = [ ] , array $ filters = [ ] ) { $ all = $ request -> all ( ) ; return $ request -> getValidation ( ) -> make ( $ all , $ rules , $ filters ) ; } | validate the form |
47,919 | public function encrypt ( $ value , $ iv = null ) { if ( empty ( $ value ) ) return false ; include_once PATH_SYSTEM . '/vendors/phpseclib0/Crypt/Rijndael.php' ; include_once PATH_SYSTEM . '/vendors/phpseclib0/Crypt/AES.php' ; $ this -> Crypt = new Crypt_AES ( ) ; $ this -> Crypt -> setKey ( $ this -> key ) ; if ( ! is... | Encrypts the given value using the included phpseclib AES implementation |
47,920 | public function decryptSecureCookie ( $ value ) { $ cookieValues = explode ( '|' , $ value , 4 ) ; if ( ( count ( $ cookieValues ) === 4 ) && ( $ cookieValues [ 1 ] == 0 || $ cookieValues [ 1 ] >= time ( ) ) ) { $ userid = $ cookieValues [ 0 ] ; $ expire = $ cookieValues [ 1 ] ; $ encrValue = $ cookieValues [ 2 ] ; $ k... | Retrieve a secured cookie value |
47,921 | public function encryptSecureCookie ( $ value , $ expire , $ userid = null ) { $ expire = ( strcmp ( strtolower ( $ expire ) , 'never' ) === 0 ? time ( ) + 60 * 60 * 24 * 6000 : $ expire ) ; if ( is_null ( $ userid ) ) $ userid = ( string ) $ this -> RequestContext -> getUserRef ( ) ; $ key = hash_hmac ( 'sha1' , $ use... | Secure a cookie value |
47,922 | abstract public function __construct ( Request $ request , $ relativeCmsUri , CmsComponent $ cmsComponent ) ; | CmsRouting constructor . |
47,923 | public static function isRequiredIntegerRange ( $ value , $ min , $ max ) { return is_int ( $ value ) && $ min <= $ value && $ max >= $ value ; } | Required value is integer in range . |
47,924 | public static function isOptionalIntegerRange ( $ value , $ min , $ max ) { if ( null === $ value ) { return true ; } return self :: isRequiredIntegerRange ( $ value , $ min , $ max ) ; } | Optional value is integer in range . |
47,925 | public static function isRequiredFloatRange ( $ value , $ min , $ max ) { return is_float ( $ value ) && $ min <= $ value && $ max >= $ value ; } | Required value is float in range . |
47,926 | public static function isOptionalFloatRange ( $ value , $ min , $ max ) { if ( null === $ value ) { return true ; } return self :: isRequiredFloatRange ( $ value , $ min , $ max ) ; } | Optional value is float in range . |
47,927 | public static function isOptionalNumberRange ( $ value , $ min , $ max ) { if ( null === $ value ) { return true ; } return self :: isRequiredNumberRange ( $ value , $ min , $ max ) ; } | Optional value is number in range . |
47,928 | public static function isRequiredNumericRange ( $ value , $ min , $ max ) { return is_numeric ( $ value ) && $ min <= $ value && $ max >= $ value ; } | Required value is numeric in range . |
47,929 | public static function isOptionalNumericRange ( $ value , $ min , $ max ) { if ( null === $ value ) { return true ; } return self :: isRequiredNumericRange ( $ value , $ min , $ max ) ; } | Optional value is numeric in range . |
47,930 | public static function isOptionalExistingKey ( $ key , array $ values ) { if ( null === $ key ) { return true ; } return self :: isRequiredExistingKey ( $ key , $ values ) ; } | Optional key exists . |
47,931 | public function setParams ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { $ this -> params = array_merge_recursive ( $ this -> params , $ key ) ; return $ this ; } $ this -> params [ $ key ] = $ value ; return $ this ; } | Set parameter data |
47,932 | protected function hasRelation ( $ key , $ value , $ relations ) { if ( is_numeric ( $ relations ) ) { if ( $ relations > 0 ) { return true ; } return false ; } foreach ( $ relations as $ prop ) { if ( $ prop == 'assets' ) { if ( $ key === 'fields' || ( ! $ this -> resolved ( $ value ) && is_object ( $ value ) && prope... | Check if relation exists |
47,933 | protected function getNestedRelations ( $ key , $ relations ) { if ( is_numeric ( $ relations ) ) { if ( $ key == 'fields' ) { return $ relations ; } if ( $ relations - 1 > 0 ) { return $ relations - 1 ; } return [ ] ; } $ nestedRelations = [ ] ; foreach ( $ relations as $ prop ) { if ( $ prop === 'assets' ) { $ nested... | Get nested relations for field |
47,934 | protected function loadQueue ( ) { $ loadQueue = self :: $ loadQueue ; foreach ( $ loadQueue as $ type => $ queries ) { foreach ( $ queries as $ query ) { $ ids = [ ] ; foreach ( $ query [ 'ids' ] as $ id ) { if ( Trunk :: has ( [ $ id , $ query [ 'relations' ] ] , $ type ) ) { $ object = Trunk :: get ( [ $ id , $ quer... | Load objects from queue |
47,935 | public function addIncludes ( $ includes ) { if ( $ includes instanceof Model ) { $ this -> addItemToInclude ( $ includes ) ; } else { foreach ( $ includes as $ item ) { $ this -> addItemToInclude ( $ item ) ; } } if ( $ includes instanceof DataTransferObject ) { $ this -> addIncludes ( $ includes -> getIncludes ( ) ) ... | Add items to include |
47,936 | public function offsetSet ( $ offset , $ value ) { if ( is_null ( $ offset ) ) { if ( ! $ this -> isCollection ) { throw new Exception ( 'You need to specify a valid key for model.' ) ; } $ this -> data [ ] = $ value ; } else { if ( $ this -> isCollection ) { $ this -> data [ $ offset ] = $ value ; return ; } $ this ->... | Set data at specific offset |
47,937 | public function offsetExists ( $ offset ) { return ( $ this -> isCollection ) ? isset ( $ this -> data [ $ offset ] ) : isset ( $ this -> data -> { $ offset } ) ; } | Check if provided offset exists |
47,938 | public function offsetUnset ( $ offset ) { if ( $ this -> isCollection ) { unset ( $ this -> data [ $ offset ] ) ; } else { unset ( $ this -> data -> { $ offset } ) ; } } | Unset the provided offset |
47,939 | public function toJson ( $ options = 0 , $ includeMetaData = false , $ nestedInclude = true , $ callback = null ) { $ data = $ this -> toArray ( $ includeMetaData , $ nestedInclude , $ callback ) ; return json_encode ( $ data , $ options ) ; } | Get the instance as an json string . |
47,940 | public function transformToArray ( $ data , $ nestedInclude = true , $ extraIncludes = [ ] , $ callback = null ) { if ( is_object ( $ data ) ) { if ( $ nestedInclude && ! $ this -> resolved ( $ data ) ) { $ objectKey = $ this -> objectKey ( $ data ) ; if ( array_key_exists ( $ objectKey , $ extraIncludes ) ) { $ data =... | Convert Object to array deep |
47,941 | protected function resolve ( $ obj ) { if ( Trunk :: has ( $ obj -> id , $ obj -> type ) ) { return $ data = Trunk :: get ( $ obj -> id , $ obj -> type ) ; } return $ obj ; } | Get resolved object form trunk if possible |
47,942 | public function getIncluded ( $ obj ) { $ includes = $ this -> getIncludes ( true ) ; $ objectKey = $ this -> objectKey ( $ obj ) ; if ( array_key_exists ( $ objectKey , $ includes ) ) { return $ includes [ $ objectKey ] ; } return $ obj ; } | Get resolved object from included |
47,943 | protected function objectKey ( $ object ) { return base64_encode ( json_encode ( [ 'id' => $ object -> id , 'type' => $ object -> type , 'relations' => $ this -> relations ] ) ) ; } | Make base64 key from object |
47,944 | public function getQueues ( array $ queueAlias ) : array { $ queues = [ ] ; foreach ( $ queueAlias as $ alias ) { $ queues [ ] = $ this -> getQueue ( $ alias ) ; } return $ queues ; } | Given an array of queueAliases return a valid queueNames array . |
47,945 | public function getQueueAliasByQueueName ( string $ queueName ) : string { return is_array ( $ this -> queues ) ? ( ( array_flip ( $ this -> queues ) [ $ queueName ] ) ?? $ queueName ) : $ queueName ; } | Return queue alias by queue name . |
47,946 | public function getButton ( $ details ) { if ( is_string ( $ details ) ) { return HtmlHelper :: get ( ) -> noContentElement ( 'input' , array ( 'type' => 'submit' , 'name' => $ details , 'value' => $ this -> translate ( ucwords ( str_replace ( '_' , ' ' , $ details ) ) ) ) ) ; } if ( isset ( $ details [ 'visible' ] ) &... | Return html code for a button . |
47,947 | public function registerSystemServices ( ) { $ factory = Yii :: $ app -> factory -> getContainer ( ) ; $ factory -> set ( 'cmsgears\social\connect\common\services\interfaces\system\IFacebookService' , 'cmsgears\social\connect\common\services\system\FacebookService' ) ; $ factory -> set ( 'cmsgears\social\connect\common... | Registers system services . |
47,948 | public function registerSystemAliases ( ) { $ factory = Yii :: $ app -> factory -> getContainer ( ) ; $ factory -> set ( 'facebookService' , 'cmsgears\social\connect\common\services\system\FacebookService' ) ; $ factory -> set ( 'googleService' , 'cmsgears\social\connect\common\services\system\GoogleService' ) ; $ fact... | Registers system aliases . |
47,949 | protected function response ( $ result ) { $ response = $ this -> container -> get ( Application :: RESPONSE ) ; if ( $ result instanceof ResponseInterface ) { return $ result ; } $ response -> stream ( ) -> write ( $ result ) ; return $ response ; } | Converts the given result into a ResponseInterface . |
47,950 | public function camelize ( $ base ) { $ callback = create_function ( '$c' , 'return strtoupper($c[1]);' ) ; if ( ! is_array ( $ base ) ) { return preg_replace_callback ( '/_([a-z])/' , $ callback , $ base ) ; } foreach ( $ base as $ key => $ val ) { unset ( $ base [ $ key ] ) ; $ newKey = preg_replace_callback ( '/_([a... | Convert strings from under_scores to CamelCase . |
47,951 | public function uncamelize ( $ base ) { $ callback = create_function ( '$c' , 'return "_" . strtolower($c[1]);' ) ; if ( ! is_array ( $ base ) ) { $ base [ 0 ] = strtolower ( $ base [ 0 ] ) ; return preg_replace_callback ( '/([A-Z])/' , $ callback , $ base ) ; } foreach ( $ base as $ key => $ val ) { unset ( $ base [ $... | Converts strings from camelCase to under_score . |
47,952 | public function addIn ( $ field , $ values , $ whereConcat = 'AND' ) { if ( ! is_array ( $ values ) ) { return $ this ; } $ field = ( 0 < count ( $ this -> wheres ) ? ' ' . $ whereConcat . ' ' . $ field : $ field ) ; $ index = 1 ; $ fields = array ( ) ; foreach ( $ values as $ value ) { $ name = ':value_' . $ index ; $... | Add In list item . |
47,953 | public function addWhere ( $ field , $ value , $ sign = '=' , $ whereConcat = 'AND' ) { $ fieldWhere = ( 0 < count ( $ this -> wheres ) ? ' ' . $ whereConcat . ' ' . $ field : $ field ) ; $ fieldBind = ':' . strtolower ( $ field ) ; if ( isset ( $ this -> binds [ $ fieldBind ] ) ) { $ counter = 0 ; while ( $ counter < ... | Add where clause . |
47,954 | public function clear ( ) { $ this -> wheres = array ( ) ; $ this -> sets = array ( ) ; $ this -> havings = array ( ) ; $ this -> orders = array ( ) ; $ this -> binds = array ( ) ; $ this -> limit = null ; $ this -> offset = null ; return $ this ; } | Clear query params |
47,955 | public function getQueryFields ( $ usePrefix = false , $ prefix = '' ) { $ fields = $ this -> fields ; if ( $ usePrefix ) { $ prefix = ( empty ( $ prefix ) ? $ this -> getTable ( ) : $ prefix ) ; $ fields = array ( ) ; foreach ( $ this -> fields as $ field ) { $ fields [ ] = $ prefix . '.' . $ field ; } } return implod... | Get fields to select |
47,956 | public function getQueryLimit ( ) { if ( $ this -> limit !== null && $ this -> offset !== null ) { return 'LIMIT ' . $ this -> offset . ', ' . $ this -> limit ; } else { if ( null !== $ this -> limit ) { return 'LIMIT ' . $ this -> limit ; } else { return '' ; } } } | Get limit clause . |
47,957 | public function count ( $ field = '*' ) { if ( $ field !== '*' && ! in_array ( $ field , $ this -> getFields ( ) ) ) { throw new \ DomainException ( __METHOD__ . '|Field is not allowed ! (field: ' . $ field . ')' ) ; } $ query = 'SELECT COUNT(' . $ field . ') AS NB_RESULTS FROM ' . $ this -> table . ' ' . $ this -> get... | Count number of results for query . |
47,958 | public function rowExists ( $ field , $ value ) { $ this -> addWhere ( $ field , $ value ) ; try { $ this -> selectOne ( ) ; return true ; } catch ( ExceptionNoData $ exception ) { return false ; } } | Check if value row exists in database .. |
47,959 | public function query ( $ query ) { $ statement = $ this -> db -> prepare ( $ query ) ; $ statement -> execute ( $ this -> binds ) ; $ this -> clear ( ) ; $ collection = array ( ) ; while ( false !== ( $ row = $ statement -> fetchObject ( ) ) ) { $ collection [ ] = $ this -> newDataInstance ( $ row , true ) ; } return ... | Fetch rows for specified query . |
47,960 | public function delete ( DataAbstract $ data ) { foreach ( $ this -> primaryKeys as $ key ) { $ this -> addWhere ( $ key , $ this -> getDataValue ( $ data , $ key ) ) ; } $ where = $ this -> getQueryWhere ( ) ; if ( empty ( $ where ) ) { throw new \ LogicException ( __METHOD__ . '| Where restriction is empty for curren... | Delete data from database . |
47,961 | public function persist ( DataAbstract $ data ) { if ( $ data -> exists ( ) ) { return $ this -> update ( $ data ) ; } else { return $ this -> insert ( $ data ) ; } } | Persist data in database . |
47,962 | public function update ( DataAbstract $ data ) { if ( ! $ data -> isUpdated ( ) ) { return false ; } $ this -> binds = array ( ) ; foreach ( $ this -> primaryKeys as $ key ) { $ this -> addWhere ( $ key , $ this -> getDataValue ( $ data , $ key ) ) ; } $ set = $ this -> getQueryFieldsSet ( $ data ) ; if ( empty ( $ set... | Update data into database |
47,963 | public function select ( ) { $ query = 'SELECT ' . $ this -> getQueryFields ( ) . ' FROM ' . $ this -> getTable ( ) . ' ' . $ this -> getQueryWhere ( ) . ' ' . $ this -> getQueryOrderBy ( ) . ' ' . $ this -> getQueryLimit ( ) ; $ statement = $ this -> db -> prepare ( $ query ) ; $ statement -> execute ( $ this -> binds... | Select all rows corresponding of where clause . |
47,964 | public function selectOne ( ) { $ this -> setLimit ( 1 ) ; $ query = 'SELECT ' . $ this -> getQueryFields ( ) . ' FROM ' . $ this -> getTable ( ) . ' ' . $ this -> getQueryWhere ( ) . ' ' . $ this -> getQueryOrderBy ( ) . ' ' . $ this -> getQueryLimit ( ) ; $ statement = $ this -> db -> prepare ( $ query ) ; $ statemen... | Select first rows corresponding to where clause . |
47,965 | protected function getCache ( DataAbstract $ data ) { if ( ! $ this -> isCacheEnabled ) { return false ; } return $ this -> cache -> get ( $ data -> getCacheKey ( ) ) ; } | Get Data object from cache if is enabled . |
47,966 | protected function setCache ( DataAbstract $ data ) { if ( ! $ this -> isCacheEnabled ) { return $ this ; } $ this -> cache -> set ( $ data -> getCacheKey ( ) , $ data ) ; return $ this ; } | Set data into cache if enabled . |
47,967 | protected function isDataUpdated ( $ data , $ field ) { if ( ! isset ( $ this -> dataNamesMap [ $ field ] [ 'property' ] ) ) { throw new \ DomainException ( 'Field have not mapping with Data instance (field: ' . $ field . ')' ) ; } $ property = $ this -> dataNamesMap [ $ field ] [ 'property' ] ; return $ data -> isUpda... | Check if data value is updated or not |
47,968 | protected function getDataValue ( $ data , $ field ) { if ( ! isset ( $ this -> dataNamesMap [ $ field ] [ 'get' ] ) ) { throw new \ DomainException ( 'Field have not mapping with Data instance (field: ' . $ field . ')' ) ; } $ method = $ this -> dataNamesMap [ $ field ] [ 'get' ] ; return $ data -> { $ method } ( ) ; ... | Get value from DataAbstract instance based on field value |
47,969 | protected function setDataValue ( $ data , $ field , $ value ) { if ( ! isset ( $ this -> dataNamesMap [ $ field ] [ 'set' ] ) ) { if ( true === $ this -> ignoreNotMappedFields ) { return $ this ; } throw new \ DomainException ( 'Field have not mapping with Data instance (field: ' . $ field . ')' ) ; } $ method = $ thi... | Set value into DataAbstract instance based on field value |
47,970 | public function initCache ( Cache $ cache , $ enableCache = false ) { $ this -> cache = $ cache ; $ this -> isCacheEnabled = $ enableCache ; if ( $ enableCache ) { $ this -> cache -> enable ( ) ; } else { $ this -> cache -> disable ( ) ; } return $ this ; } | Set cache instance & enable cache if it is specified . |
47,971 | public static function boot ( $ filename = null , Injector $ injector = null , $ directory = null ) { $ directory = $ directory === null ? getcwd ( ) : $ directory ; $ injector = $ injector === null ? new Injector : $ injector ; $ system = new Filesystem ( new Local ( $ directory ) ) ; $ injector -> share ( $ system ) ... | Prepares the console application . |
47,972 | protected static function paths ( Blueprint $ blueprint , $ directory , $ filename = null ) { $ yaml = file_exists ( $ filename ) ? file_get_contents ( $ filename ) : '' ; $ yaml = str_replace ( array ( '\\' , '/' ) , DIRECTORY_SEPARATOR , $ yaml ) ; $ yaml = str_replace ( '%%CURRENT_DIRECTORY%%' , $ directory , $ yaml... | Prepares the paths that are defined from a YAML file . |
47,973 | public function iShouldSeeInTheOutput ( $ string ) { if ( strpos ( $ this -> output , $ string ) === false ) { throw new Exception ( sprintf ( 'Did not see "%s" in output "%s"' , $ string , $ this -> output ) ) ; } } | Validate command output . |
47,974 | protected function decodeRequest ( $ class , Context $ ctx = null ) { $ container = $ this -> container ; $ request = $ container -> get ( 'request' ) ; $ serializerFormat = $ this -> container -> get ( 'ac_web_services.negotiator' ) -> negotiateRequestFormat ( $ request ) ; $ data = $ request -> getContent ( ) ; if ( ... | Convenience method for decoding incoming API data . The data format is determined via a negotiation service and then deserialized . |
47,975 | protected function validate ( $ obj ) { $ errors = $ this -> container -> get ( 'validator' ) -> validate ( $ obj ) ; if ( count ( $ errors ) > 0 ) { throw new ValidationException ( $ errors ) ; } } | Convenience validation method that will automatically throw custom ValidationExceptions when validation fails . |
47,976 | public function toSQL ( Parameters $ params , bool $ inner_clause ) { $ groups = $ this -> getGroups ( ) ; $ having = $ this -> getHaving ( ) ; if ( count ( $ groups ) === 0 ) throw new QueryException ( "No groups in GROUP BY clause" ) ; $ drv = $ params -> getDriver ( ) ; $ parts = array ( ) ; foreach ( $ groups as $ ... | Write a GROUPBY clause as SQL query syntax |
47,977 | protected function getCartProductInCart ( CartProductInterface $ cartProduct , CartInterface $ cart ) { return $ this -> getRepository ( ) -> findOneBy ( [ 'id' => $ cartProduct -> getId ( ) , 'cart' => $ cart ] ) ; } | Returns an item from cart |
47,978 | public function setUserClass ( string $ classname ) { if ( ! class_exists ( $ classname ) || ! is_subclass_of ( $ classname , UserInterface :: class ) ) throw new DomainException ( "Invalid user class: $classname" ) ; $ this -> user_class = $ classname ; return $ this ; } | Set the UserInterface class that represents users . |
47,979 | public function setGroupClass ( string $ classname ) { if ( ! class_exists ( $ classname ) || ! is_subclass_of ( $ classname , GroupInterface :: class ) ) throw new DomainException ( "Invalid group class: $classname" ) ; $ this -> group_class = $ classname ; return $ this ; } | Set the GroupInterface class that represents groups . |
47,980 | public function getUserFromSession ( Session $ session ) { $ cl = $ this -> getUserClass ( ) ; $ this -> user = new $ cl ; $ this -> user -> obtainFromSession ( $ session ) ; return $ this -> user ; } | Obtain the current user from the active session |
47,981 | public function getUser ( string $ userid ) { $ cl = $ this -> getUserClass ( ) ; $ user = new $ cl ; return $ user -> obtainByUserID ( $ userid ) ; } | Obtain a user by its user ID . |
47,982 | public function getGroup ( string $ groupid ) { $ cl = $ this -> getGroupClass ( ) ; $ group = new $ cl ; return $ group -> obtainByGroupID ( $ groupid ) ; } | Obtain a group by its group ID . |
47,983 | public function login ( string $ username , string $ password , Session $ session ) { if ( $ session -> has ( 'authentication' , 'user_id' ) ) { throw new AuthenticationError ( "Already logged in" , AuthenticationError :: DUPLICATE_SESSION ) ; } $ cl = $ this -> getUserClass ( ) ; $ this -> user = new $ cl ; try { $ th... | Check if the provided details contain a valid login . |
47,984 | public function hash ( string $ password ) { $ algorithm = $ this -> config -> dget ( 'algorithm' , PASSWORD_DEFAULT ) ; $ options [ 'cost' ] = $ this -> config -> dget ( 'cost' , 10 ) ; return password_hash ( $ password , $ algorithm , $ options ) ; } | Create a hash of the password |
47,985 | public function verify ( string $ password , string $ hash ) { if ( substr ( $ hash , 0 , 1 ) !== "$" ) { $ salt = $ this -> config -> dget ( 'salt' , '' ) ; $ append = $ this -> config -> dget ( 'salt_placement' , 'append' ) === 'append' ; $ to_hash = $ append ? $ password . $ salt : $ salt . $ password ; $ pw_hash = ... | Check if the password matches the provided hash . The password should come from user input the hash from persistent storage . |
47,986 | public function needsRehash ( string $ hash ) { if ( substr ( $ hash , 0 , 1 ) !== "$" ) return true ; $ algorithm = $ this -> config -> dget ( 'algorithm' , PASSWORD_DEFAULT ) ; $ options [ 'cost' ] = $ this -> config -> dget ( 'cost' , 10 ) ; return password_needs_rehash ( $ hash , $ algorithm , $ options ) ; } | Check if the password needs a rehash |
47,987 | public function checkLength ( $ value ) { if ( strlen ( $ value ) != 8 ) { $ this -> setCheck ( false ) ; } else { $ this -> setCheck ( true ) ; } return parent :: checkLength ( $ value ) ; } | Overrides parent checkLength |
47,988 | protected function getFluidTemplateObject ( $ filename ) { $ view = GeneralUtility :: makeInstance ( StandaloneView :: class ) ; $ view -> setLayoutRootPaths ( [ 'EXT:backend/Resources/Private/Layouts' ] ) ; if ( \ Gilbertsoft \ Warranty \ Utility \ Adapter :: isCompatVersion ( '8.7' ) ) { $ view -> setPartialRootPaths... | Returns a new standalone view shorthand function |
47,989 | protected function parseFile ( $ file ) { $ this -> file = $ file ; if ( ! strncasecmp ( __FILE__ , 'phar://' , 7 ) ) { $ this -> file = tempnam ( sys_get_temp_dir ( ) , 'Wordlists' ) ; copy ( $ file , $ this -> file ) ; } $ this -> db = new \ PDO ( 'sqlite:' . $ this -> file ) ; $ metadata = $ this -> db -> query ( 'S... | Parse the content of a SQLite file representing a list of words . |
47,990 | public function count ( ) { $ this -> countQuery -> execute ( ) ; $ res = $ this -> countQuery -> fetchColumn ( ) ; $ this -> countQuery -> closeCursor ( ) ; return ( int ) $ res ; } | Returns the number of words in the list . |
47,991 | public function findWord ( $ word ) { $ key = $ this -> collator -> getSortKey ( $ word ) ; if ( substr ( $ key , - 1 ) === "\0" ) { $ key = substr ( $ key , 0 , - 1 ) ; } $ this -> existsQuery -> execute ( array ( ':key' => $ key ) ) ; $ res = $ this -> existsQuery -> fetchColumn ( ) ; $ this -> existsQuery -> closeCu... | Look for a word in the list . |
47,992 | public function offsetGet ( $ offset ) { if ( ! is_int ( $ offset ) ) { throw new \ Erebot \ InvalidValueException ( 'An integer was expected' ) ; } $ this -> getQuery -> execute ( array ( ':offset' => $ offset ) ) ; $ res = $ this -> getQuery -> fetchColumn ( ) ; $ this -> getQuery -> closeCursor ( ) ; if ( $ res == '... | Returns the word at the given offset . |
47,993 | public function getMetadata ( $ type ) { if ( $ type == self :: METADATA_NAME ) { return $ this -> name ; } if ( $ type == self :: METADATA_FILE ) { return $ this -> file ; } if ( ! array_key_exists ( $ type , $ this -> metadata ) ) { throw new \ Erebot \ InvalidValueException ( 'Invalid metadata type "' . $ type . '"'... | Returns metadata associated with the list . |
47,994 | public function insert ( $ q , $ data ) { if ( is_string ( $ q ) ) { $ this -> defaults [ 'table' ] = $ q ; $ q = [ ] ; } extract ( $ this -> defaults ) ; extract ( $ q ) ; if ( ! $ table ) throw new Exception ( "table [$tabel] not defined" , 1 ) ; $ sql = 'INSERT INTO ' . $ table . ' ' . '(' . implode ( ', ' , array_k... | inserts a record |
47,995 | public function query ( $ sql , $ data = [ ] ) { $ this -> _init ( ) ; try { $ q = $ this -> db -> prepare ( $ sql ) ; } catch ( PDOException $ e ) { throw new Exception ( $ e -> getMessage ( ) ) ; } foreach ( $ data as $ k => $ v ) { $ $ k = $ v ; $ q -> bindParam ( ':' . $ k , $ $ k ) ; } $ result = $ q -> execute ( ... | Verifies if a condition can return records |
47,996 | public function generateProxyCode ( \ ReflectionClass $ ref ) { $ methods = $ this -> collectProxyMethods ( $ ref ) ; $ implements = [ '\KoolKode\Context\Scope\ScopedProxyInterface' ] ; $ code = 'namespace ' . $ ref -> getNamespaceName ( ) . ' { ' ; $ code .= 'if(!class_exists(' . var_export ( $ ref -> name . '__scoped... | Generates the PHP code of a scoped proxy for the given type . |
47,997 | protected function collectProxyMethods ( \ ReflectionClass $ ref ) { $ methods = [ ] ; foreach ( $ ref -> getMethods ( ) as $ method ) { if ( $ method -> isStatic ( ) || $ method -> isPrivate ( ) ) { continue ; } if ( substr ( $ method -> getName ( ) , 0 , 2 ) == '__' ) { continue ; } if ( $ method -> isFinal ( ) ) { t... | Collects all public instance methods of the given type using reflection . |
47,998 | private function addMeta ( $ page , $ key , $ value ) { $ meta = new PageMeta ( ) ; $ meta -> setMetaKey ( $ key ) ; $ meta -> setMetaValue ( $ value ) ; $ meta -> setPage ( $ page ) ; return $ meta ; } | Add meta to page |
47,999 | protected function pushKeys ( $ namespace , $ key , $ reference ) { $ fullKey = $ this -> getPrefix ( ) . sha1 ( $ namespace ) . ':' . $ key ; foreach ( explode ( '|' , $ namespace ) as $ segment ) { $ this -> store -> connection ( ) -> sadd ( $ this -> referenceKey ( $ segment , $ reference ) , $ fullKey ) ; } } | Store a reference to the cache key against the reference key . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.