idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
236,900 | public function maketbodyrows ( $ query , $ rowdesc , $ callback = null , & $ retresult = false , $ delim = false ) { list ( $ result , $ num ) = $ this -> query ( $ query , true ) ; if ( ! $ num ) { return false ; } if ( $ retresult !== false ) $ retresult = $ result ; $ rdelimlft = $ rdelimrit = "" ; if ( ! $ delim )... | Make Tbody Row |
236,901 | public function maketable ( $ query , array $ extra = null ) { $ table = "<table" ; if ( $ extra [ 'attr' ] ) { $ attr = $ extra [ 'attr' ] ; foreach ( $ attr as $ k => $ v ) { $ table .= " $k='$v'" ; } } $ table .= ">\n<thead>\n<tr>%<th>*</th>%</tr>\n</thead>" ; $ rowdesc = "<tr><td>*</td></tr>" ; $ delim = array ( "<... | Make a full table |
236,902 | protected function _initParent ( $ message = '' , $ code = 0 , RootException $ previous = null ) { parent :: __construct ( $ message , $ code , $ previous ) ; } | Calls the parent constructor . |
236,903 | public function explainPerms ( $ permissionNumber ) { $ firstFlag = $ this -> matchFirstFlagSingle ( $ permissionNumber ) ; $ permissionsString = substr ( sprintf ( '%o' , $ permissionNumber ) , - 4 ) ; $ numericalPermissions = $ this -> numericalPermissionsArray ( ) ; return [ 'Permissions' => $ permissionNumber , 'Co... | Returns an array with meaningfull content of permissions |
236,904 | public function create ( string $ className , array $ bindings = [ ] ) { try { $ class = new ReflectionClass ( $ className ) ; } catch ( ReflectionException $ ex ) { throw new ContainerException ( 'Failed to create reflection class from given class name.' ) ; } $ out = null ; if ( $ class -> getConstructor ( ) !== null... | Create a instance of given class name . The injector will try to handle constructor injection if it fails it will throw an exception . |
236,905 | public function prepareTitleForPersist ( $ title ) { $ transformedTitle = trim ( $ title ) ; $ transformedTitle = strip_tags ( $ transformedTitle ) ; $ transformedTitle = filter_var ( $ transformedTitle , FILTER_SANITIZE_STRING ) ; $ transformedTitle = ucwords ( $ transformedTitle ) ; return $ transformedTitle ; } | Transform title for persist . |
236,906 | public function prepareDescriptionForPersist ( $ description ) { $ description = html_entity_decode ( $ description ) ; $ description = strip_tags ( $ description ) ; $ description = filter_var ( $ description , FILTER_SANITIZE_STRING ) ; $ description = str_replace ( "\xc2\xa0" , '' , $ description ) ; $ description =... | Transform description for persist . |
236,907 | public function prepareSlugForPersist ( $ title , $ slug , $ id = false ) { $ separator = '-' ; if ( $ slug == "" ) { $ flip = $ separator == '-' ? '_' : '-' ; $ title = html_entity_decode ( $ title ) ; $ title = strip_tags ( $ title ) ; $ title = filter_var ( $ title , FILTER_SANITIZE_STRING ) ; $ title = str_replace ... | Prepare slug for persist . |
236,908 | public function isManuallyChangedSlugInEditForm ( $ slug , $ id = false ) { if ( ! $ id ) return false ; $ record = DB :: table ( $ this -> model -> table ) -> where ( 'id' , $ id ) -> first ( ) ; if ( $ record -> slug == $ slug ) { return false ; } else { return true ; } } | Was the slug changed in the edit form? |
236,909 | public function doesSlugAlreadyExist ( $ slug ) { $ rowCount = DB :: table ( $ this -> model -> table ) -> where ( 'slug' , $ slug ) -> count ( ) ; if ( $ rowCount > 0 ) return $ rowCount ; return 0 ; } | Does the slug already exist in the table? |
236,910 | public function prepareCanonicalURLForPersist ( $ slug ) { $ baseURL = rtrim ( config ( 'app.url' ) , "/" ) ; if ( $ this -> model -> table == "posts" ) $ type = "blog" ; return $ baseURL . '/' . $ slug ; } | Transform canonical_url for persist . |
236,911 | public function prepareURLForPersist ( $ url ) { if ( substr ( $ url , 0 , 7 ) == "http://" ) return $ url ; if ( substr ( $ url , 0 , 8 ) == "https://" ) return $ url ; $ washedUrl = "http://" ; $ washedUrl .= $ url ; return $ url ; } | Wash URL for persist . |
236,912 | public function prepareExcerptForPersist ( $ excerpt = "" , $ content ) { $ chars_to_excerpt = config ( 'lasallecmsapi.how_many_initial_chars_of_content_field_for_excerpt' ) ; if ( $ excerpt == "" ) { $ excerpt = $ content ; $ excerpt = html_entity_decode ( $ excerpt ) ; $ excerpt = strip_tags ( $ excerpt ) ; $ excerpt... | Transform excerpt for persist . |
236,913 | public function prepareMetaDescriptionForPersist ( $ meta_description = "" , $ excerpt ) { if ( $ meta_description == "" ) return $ excerpt ; $ meta_description = html_entity_decode ( $ meta_description ) ; $ meta_description = strip_tags ( $ meta_description ) ; $ meta_description = filter_var ( $ meta_description , F... | Transform meta_description for persist . |
236,914 | public function prepareCompositeTitleForPersist ( $ fieldsToConcatenate , $ data ) { $ composite_title = "" ; $ count = count ( $ fieldsToConcatenate ) ; $ i = 1 ; foreach ( $ fieldsToConcatenate as $ fieldToConcatenate ) { if ( ( $ data [ $ fieldToConcatenate ] == "" ) || ( ! $ data [ $ fieldToConcatenate ] ) || ( emp... | Concatenate fields for the composite Title field |
236,915 | public function prepareRelatedTableForPersist ( $ field , $ data ) { if ( ( ( $ data == "" ) || ( $ data == null ) || ( ! $ data ) || ( empty ( $ data ) ) ) && ( $ field [ 'nullable' ] ) ) { $ data = null ; } return $ data ; } | Prepare foreign key field for persist . |
236,916 | public function genericWashText ( $ text ) { $ text = strip_tags ( $ text ) ; $ text = filter_var ( $ text , FILTER_SANITIZE_STRING ) ; $ text = str_replace ( "\xc2\xa0" , '' , $ text ) ; $ text = str_replace ( "'" , '' , $ text ) ; $ text = trim ( $ text ) ; return $ text ; } | A generic wash of plain ol text . |
236,917 | public function genericCreateSlug ( $ text ) { $ separator = '-' ; $ flip = $ separator == '-' ? '_' : '-' ; $ slug = $ this -> genericWashText ( $ text ) ; $ slug = preg_replace ( '![' . preg_quote ( $ flip ) . ']+!u' , $ separator , $ slug ) ; $ slug = preg_replace ( '![^' . preg_quote ( $ separator ) . '\pL\pN\s]+!u... | A generic method to create a slug based on any string . |
236,918 | public function onlineUsers ( ) : int { $ builder = $ this -> builder ( ) -> addSelect ( 'COUNT(DISTINCT([uid])) count' ) -> andWhere ( '[inserted] > %dt' , ( new \ DateTime ) -> modify ( '-' . $ this -> onlineTime . ' minute' ) ) -> andWhere ( '[timeOnPage] IS NOT null' ) ; return $ this -> execute ( $ builder ) -> fe... | Vrati online uzivatele |
236,919 | public function findVisitsHours ( Range $ interval , bool $ useTime = false ) : ? Result { $ date = $ useTime ? '%dt' : 'DATE(%dt)' ; $ subQuery = 'SELECT ' . 'DATE_FORMAT([inserted], "%%Y-%%m-%%d %%H:00:00") datefield, ' . 'COUNT([uid]) visits ' . 'FROM %table ' . 'WHERE ' . ( $ useTime ? '[inserted]' : 'DATE([inserte... | Vrati navstevy po hodinach |
236,920 | public function getByNameFirst ( $ value ) { $ users = [ ] ; foreach ( $ this as $ user ) { if ( $ user -> get ( 'nameFirst' ) ) { $ users [ ] = $ user ; } } return new $ this ( $ users ) ; } | example usage of more specific iterator will tidy the controllers even further |
236,921 | protected function inflateColumns ( $ columns ) { $ inflatedColumns = [ ] ; foreach ( $ columns as $ key => $ value ) { $ tableColumn = $ value ; $ label = ! is_numeric ( $ key ) ? $ key : null ; if ( is_string ( $ tableColumn ) ) { $ value = ( string ) $ value ; $ tableColumn = $ this -> createColumnFromString ( $ val... | Expands the columns array creating TableColumn objects where needed . |
236,922 | protected function getDataForPresenter ( $ dataKey , $ viewIndex = false ) { if ( ! isset ( $ this -> currentRow [ $ dataKey ] ) ) { return $ this -> model -> getBoundValue ( $ dataKey , $ viewIndex ) ; } $ value = $ this -> currentRow [ $ dataKey ] ; if ( $ value instanceof Model ) { return $ value -> UniqueIdentifier... | Provides model data to the requesting presenter . |
236,923 | public function getTemplate ( $ templatePath ) { $ absoluteTemplateFilePath = $ this -> getTemplateFilePath ( $ templatePath ) ; if ( ! $ absoluteTemplateFilePath ) { return ; } extract ( $ this -> getArrayCopy ( ) ) ; ob_start ( ) ; include $ absoluteTemplateFilePath ; $ content = ob_get_contents ( ) ; ob_end_clean ( ... | converts stored key values in iterator to output from template path requested |
236,924 | private function loadCustomerData ( ) { $ custId = $ this -> registry -> registry ( \ Magento \ Customer \ Controller \ RegistryConstants :: CURRENT_CUSTOMER_ID ) ; if ( $ custId ) { $ query = $ this -> qLoad -> build ( ) ; $ conn = $ query -> getConnection ( ) ; $ bind = [ QLoad :: BND_CUST_ID => $ custId ] ; $ rs = $... | Load block s working data before rendering . |
236,925 | public function getContent ( ) { foreach ( $ this -> dom -> documentElement -> childNodes as $ node ) { if ( $ node -> nodeName == 'content' ) { return $ node ; } } return null ; } | Gets the content section . |
236,926 | function log ( $ message , $ type = null , $ explicit = false ) { try { $ time = date ( 'Y-m-d|H:i:s' ) ; if ( $ type === null ) { $ this -> appendToFile ( date ( 'Y/m/d' ) , "[$time] $message" , $ explicit ) ; } else { $ this -> appendToFile ( $ type , "[$time] $message" , $ explicit ) ; } } catch ( \ Exception $ e ) ... | Logs a message . The type can be used as a hint to the logger on how to log the message . If the logger doesn t understand the type a file with the type name will be created as default behavior . |
236,927 | protected function appendToFile ( $ logfile , $ logstring , $ explicit = false ) { $ class = \ hlin \ PHP :: unn ( __CLASS__ ) ; $ sig = crc32 ( $ logstring ) ; $ filesig = crc32 ( $ sig . $ logfile ) ; if ( ! in_array ( $ filesig , $ this -> filesigs ) ) { $ fs = $ this -> fs ; $ filepath = $ this -> logspath . '/' . ... | Appeds to the logfile . The logfile is relative to the logs directory . If the logfile doesn t exist yet the system will create it . The . log extention is automatically appended along with a single newline character . |
236,928 | public function setValueAttribute ( $ value ) { if ( ! $ this -> isValid ( $ value ) ) { throw new InvalidValueException ( "The value in the field '" . get_class ( $ this ) . "' is invalid" ) ; } $ this -> attributes [ 'value' ] = $ this -> prepareValue ( $ value ) ; } | Validate and set the value |
236,929 | public function getArchitectureFromUserAgent ( $ userAgent , $ targetToAnalyze = 'os' ) { switch ( $ targetToAnalyze ) { case 'browser' : $ aReturn = $ this -> getArchitectureFromUserAgentBrowser ( $ userAgent ) ; break ; case 'os' : $ aReturn = $ this -> getArchitectureFromUserAgentOperatingSystem ( $ userAgent ) ; br... | Return CPU architecture details from given user agent |
236,930 | private function getClientBrowser ( \ DeviceDetector \ DeviceDetector $ deviceDetectorClass , $ userAgent ) { $ this -> autoPopulateSuperGlobals ( ) ; $ browserInfoArray = [ 'architecture' => $ this -> getArchitectureFromUserAgent ( $ userAgent , 'browser' ) , 'connection' => $ this -> brServerGlobals -> server -> get ... | Provides details about browser |
236,931 | private function getClientBrowserAccepted ( ) { $ this -> autoPopulateSuperGlobals ( ) ; $ sReturn = [ 'accept' => $ this -> brServerGlobals -> server -> get ( 'HTTP_ACCEPT' ) , 'accept_encoding' => $ this -> brServerGlobals -> server -> get ( 'HTTP_ACCEPT_ENCODING' ) , ] ; if ( ! is_null ( $ this -> brServerGlobals ->... | Returns accepted things setting from the client browser |
236,932 | public function getClientBrowserDetails ( $ returnType = [ 'Browser' , 'Device' , 'OS' ] , $ tmpFolder = null ) { $ userAgent = $ this -> getUserAgentByCommonLib ( ) ; $ devDetectClass = new \ DeviceDetector \ DeviceDetector ( $ userAgent ) ; if ( is_null ( $ tmpFolder ) ) { $ tmpFolder = '../../tmp/DoctrineCache/' ; }... | Provides various details about browser based on user agent |
236,933 | private function getClientBrowserDevice ( \ DeviceDetector \ DeviceDetector $ deviceDetectorClass ) { $ this -> autoPopulateSuperGlobals ( ) ; $ clientIp = $ this -> brServerGlobals -> getClientIp ( ) ; return [ 'brand' => $ deviceDetectorClass -> getDeviceName ( ) , 'ip' => $ clientIp , 'ip direct' => $ this -> brServ... | Returns client device details from client browser |
236,934 | private function getClientBrowserOperatingSystem ( \ DeviceDetector \ DeviceDetector $ deviceDetectorClass , $ userAgent ) { $ aReturn = $ deviceDetectorClass -> getOs ( ) ; $ aReturn [ 'architecture' ] = $ this -> getArchitectureFromUserAgent ( $ userAgent , 'os' ) ; $ operatingSystem = new \ DeviceDetector \ Parser \... | Returns client operating system details from client browser |
236,935 | public function getUserAgentByCommonLib ( ) { $ this -> autoPopulateSuperGlobals ( ) ; if ( ! is_null ( $ this -> brServerGlobals -> get ( 'ua' ) ) ) { return $ this -> brServerGlobals -> get ( 'ua' ) ; } return $ this -> getUserAgentByCommonLibDetection ( ) ; } | Captures the user agent |
236,936 | public function viewAction ( ) { $ comments = new \ Phpmvc \ Comment \ CommentsInSession ( ) ; $ comments -> setDI ( $ this -> di ) ; $ all = $ comments -> findAll ( ) ; $ this -> views -> add ( 'comment/comments' , [ 'comments' => $ all , ] ) ; } | View all comments . |
236,937 | public function removeAllAction ( ) { $ isPosted = $ this -> request -> getPost ( 'doRemoveAll' ) ; if ( ! $ isPosted ) { $ this -> response -> redirect ( $ this -> request -> getPost ( 'redirect' ) ) ; } $ comments = new \ Phpmvc \ Comment \ CommentsInSession ( ) ; $ comments -> setDI ( $ this -> di ) ; $ comments -> ... | Remove all comments . |
236,938 | protected function addQueryString ( $ uri , array $ parameters ) { if ( ! is_null ( $ fragment = parse_url ( $ uri , PHP_URL_FRAGMENT ) ) ) { $ uri = preg_replace ( '/#.*/' , '' , $ uri ) ; } $ uri .= $ this -> getRouteQueryString ( $ parameters ) ; return is_null ( $ fragment ) ? $ uri : $ uri . "#{$fragment}" ; } | Add a query string to the URI . |
236,939 | protected function getRouteScheme ( $ route ) { if ( $ route -> httpOnly ( ) ) { return $ this -> getScheme ( false ) ; } elseif ( $ route -> httpsOnly ( ) ) { return $ this -> getScheme ( true ) ; } return $ this -> getScheme ( null ) ; } | Get the scheme for the given route . |
236,940 | public function isValidUrl ( $ path ) { if ( Str :: startsWith ( $ path , [ '#' , '//' , 'mailto:' , 'tel:' , 'http://' , 'https://' ] ) ) return true ; return filter_var ( $ path , FILTER_VALIDATE_URL ) !== false ; } | Determine if the given path is a valid URL . |
236,941 | protected function genNonce ( ) { $ chars = '1234567890abcdefghijklmnopqrstuvwxyz' ; $ rnd_string = '' ; $ num_chars = strlen ( $ chars ) ; $ size = mt_rand ( 41 , 59 ) ; for ( $ i = 0 ; $ i < $ size ; $ i ++ ) { $ rnd_string .= $ chars [ mt_rand ( 0 , $ num_chars - 1 ) ] ; } return $ rnd_string ; } | Generating a random string which will be used as nonce |
236,942 | protected function genHash ( $ data , $ nonce ) { $ token = $ this -> getConfig ( ) -> getStorage ( ) -> getAccessToken ( ) -> getAccessToken ( ) ; return sha1 ( urlencode ( $ data ) . $ this -> getConfig ( ) -> getAppId ( ) . urlencode ( sha1 ( $ token ) ) . urlencode ( $ nonce ) . $ this -> getConfig ( ) -> getAppSec... | Generating the required hash value from the data nonce and the other information that is nearly static |
236,943 | public function handle ( $ server , $ get , $ post ) { $ smalldb = null ; $ path = trim ( isset ( $ server [ 'PATH_INFO' ] ) ? $ server [ 'PATH_INFO' ] : '' , '/' ) ; $ path = ( $ path == '' ? array ( ) : explode ( '/' , $ path ) ) ; $ path_tail = end ( $ path ) ; if ( strpos ( $ path_tail , '!' ) !== FALSE ) { list ( ... | Interpret the HTTP request |
236,944 | public function compileSelect ( Builder $ query ) { $ this -> beforeGet ( $ query ) ; return $ this -> grammar -> compileSelect ( $ query ) ; } | Compile a select query into SQL |
236,945 | public function compileInsert ( Builder $ query , array $ values ) { foreach ( $ values as & $ row ) { $ this -> beforePut ( $ row ) ; } unset ( $ row ) ; $ this -> remapWheres ( $ query ) ; $ sql = $ this -> grammar -> compileInsert ( $ query , $ values ) ; if ( $ this -> replace_into ) { $ sql = preg_replace ( '/^ins... | Compile an insert statement into SQL |
236,946 | public function compileInsertGetId ( Builder $ query , $ values , $ sequence ) { $ this -> beforePut ( $ values ) ; $ this -> remapWheres ( $ query ) ; $ sql = $ this -> grammar -> compileInsertGetId ( $ query , $ values , $ sequence ) ; if ( $ this -> replace_into ) { $ sql = preg_replace ( '/^insert into/i' , 'replac... | Compile an insert and get ID statement into SQL |
236,947 | public function compileUpdate ( Builder $ query , $ values ) { $ this -> beforePut ( $ values ) ; $ this -> remapWheres ( $ query ) ; return $ this -> grammar -> compileUpdate ( $ query , $ values ) ; } | Compile an update statement into SQL |
236,948 | public function compileDelete ( Builder $ query ) { $ this -> remapWheres ( $ query ) ; return $ this -> grammar -> compileDelete ( $ query ) ; } | Compile a delete statement into SQL |
236,949 | private function registerEvents ( ) { foreach ( $ this -> getSetting ( 'events' , [ ] ) as $ event => $ listeners ) { foreach ( $ listeners as $ listener ) { Event :: bind ( $ event , $ listener ) ; } } } | Register custom events . |
236,950 | protected function resetBinds ( $ prefix = null ) { if ( $ prefix === null ) { $ this -> builder -> setParameters ( [ ] ) ; return ; } $ params = ( array ) $ this -> builder -> getParameters ( ) ; $ types = ( array ) $ this -> builder -> getParameterTypes ( ) ; foreach ( array_keys ( $ params ) as $ key ) { if ( strpos... | Removes bound values by their prefix If prefix is null - clears all bound values |
236,951 | protected function addFluentIndexes ( ) { foreach ( $ this -> columns as $ column ) { foreach ( [ 'primary' , 'unique' , 'index' ] as $ index ) { if ( $ column -> $ index === true ) { $ this -> $ index ( $ column -> name ) ; continue 2 ; } elseif ( isset ( $ column -> $ index ) ) { $ this -> $ index ( $ column -> name ... | Add the index commands fluently specified on columns . |
236,952 | public static function fromIdentifierOrAlias ( $ identifierOrAlias ) { $ alias = $ identifierOrAlias ; $ identifier = 'Plain' ; if ( isset ( self :: $ aliasToIdentifierMap [ $ identifierOrAlias ] ) ) { $ identifier = self :: $ aliasToIdentifierMap [ $ identifierOrAlias ] ; } return new static ( $ alias , $ identifier )... | Instantiates the brush by identifier or alias . |
236,953 | public static function permissions ( ) : array { $ permissions = parent :: permissions ( ) ; $ ci = & get_instance ( ) ; $ ci -> load -> model ( 'blog/blog_model' ) ; $ blogs = $ ci -> blog_model -> getAll ( ) ; $ out = array ( ) ; if ( ! empty ( $ blogs ) ) { foreach ( $ blogs as $ blog ) { $ permissions [ $ blog -> i... | Returns an array of permissions which can be configured for the user |
236,954 | static public function manufacture ( $ conn , Cache $ cache_driver , Reader $ annotation_reader , array $ entity_paths , $ autogenerate_strategy = false , $ ensure_production_settings = false , $ doctrine_annotations_file_path = self :: DOCTRINE_ANNOTATIONS_FILE_PATH , $ proxy_namespace = "Doctrine\\Proxies" , $ proxy_... | Manufactures an EntityManager instance using the passed configuration . |
236,955 | public function insertStmts ( array $ stmts , $ offset = 0 , $ remove = 0 ) { if ( false === $ offset ) { $ offset = count ( $ this -> stmts ) ; } elseif ( false === $ remove ) { $ remove = count ( $ this -> stmts ) ; } array_splice ( $ this -> stmts , $ offset , $ remove , $ stmts ) ; return $ this ; } | Insert or replace some statements . |
236,956 | public function getItems ( ) { $ res = array ( ) ; foreach ( $ this -> iter as $ item ) { if ( count ( $ res ) == 10 ) break ; $ res [ ] = $ item -> CloneInstance ( ) ; } return $ res ; } | Return the first 10 items of the iterator |
236,957 | public function findBy ( $ field , $ value ) { $ model_class = $ this -> getModelName ( ) ; return $ model_class :: where ( $ field , $ value ) -> first ( ) ; } | Find a record by a custom field |
236,958 | public function create ( array $ data ) : Model { $ model_class = $ this -> getModelName ( ) ; return $ this -> postCreate ( $ data , $ model_class :: create ( $ this -> preCreate ( $ this -> parseData ( $ data ) ) ) ) ; } | Create and return the model object |
236,959 | public function delete ( $ id ) { if ( $ record = $ this -> find ( $ id ) ) { if ( $ this -> preDelete ( $ id , $ record ) ) { return $ this -> postDelete ( $ id , $ record -> delete ( ) , $ record ) ; } } else { $ this -> throwModelNotFoundException ( $ id ) ; } } | Delete a record by ID |
236,960 | public function parseData ( array $ data ) : array { if ( $ this -> getTransformer ( ) instanceof RequestTransformerContract ) { return $ this -> getTransformer ( ) -> transformRequestData ( $ data ) ; } return $ data ; } | Parse the data using the request method of the transformer if it exists |
236,961 | public function transformItem ( Model $ item , $ includes = [ ] , TransformerContract $ transformer = null ) { $ this -> fractal_manager -> parseIncludes ( $ includes ) ; $ transformer = is_null ( $ transformer ) ? $ this -> getTransformer ( ) : $ transformer ; $ resource = new Item ( $ item , $ transformer , $ this ->... | Pass a model through the transformer |
236,962 | public function newQuery ( ) : QueryBuilder { $ model = $ this -> container -> make ( $ this -> getModelName ( ) ) ; if ( ! $ model instanceof Model ) { throw new RepositoryException ( "Class {$this->model()} must be an instance of " . Model :: class ) ; } return $ model -> newQuery ( ) ; } | Create a new query instance |
236,963 | protected function throwModelNotFoundException ( $ id ) { throw new ModelNotFoundException ( 'Model not found for ID ' . $ id . ' on table ' . $ this -> container -> make ( $ this -> getModelName ( ) ) -> getTable ( ) ) ; } | Throw an exception when a model is not found |
236,964 | public function parent ( ) { return $ this -> filter ( [ 'lft__lt' => $ this -> getModel ( ) -> lft , 'rgt__gt' => $ this -> getModel ( ) -> rgt , 'level' => $ this -> getModel ( ) -> level - 1 , 'root' => $ this -> getModel ( ) -> root , ] ) ; } | Named scope . Gets parent of node . |
236,965 | protected function rebuildLftRgt ( string $ table ) { $ builder = QueryBuilderFactory :: getQueryBuilder ( $ this -> getConnection ( ) ) ; $ subQuerySql = ( clone $ builder ) -> clear ( ) -> select ( 'tt.parent_id' ) -> table ( $ table , 'tt' ) -> where ( 'tt.parent_id=t.id' ) -> toSQL ( ) ; $ sql = ( clone $ builder )... | Find and delete broken branches without root parent and with incorrect lft rgt . |
236,966 | public function toHierarchy ( $ collection ) : array { $ trees = [ ] ; if ( count ( $ collection ) > 0 ) { $ stack = [ ] ; foreach ( $ collection as $ item ) { $ item [ $ this -> treeKey ] = [ ] ; $ l = count ( $ stack ) ; while ( $ l > 0 && $ stack [ $ l - 1 ] [ 'level' ] >= $ item [ 'level' ] ) { array_pop ( $ stack ... | Make hierarchy array by level . |
236,967 | public static function writable ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } return ( is_dir ( $ path ) && is_writable ( $ path ) ) ; } | Check if directory is writable |
236,968 | public static function create ( $ path , $ chmod = 0755 ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( self :: exist ( $ path ) ) { return false ; } return @ mkdir ( $ path , $ chmod , true ) ; } | Create directory with recursive support . |
236,969 | public static function remove ( $ path ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } foreach ( new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ path , FilesystemIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: CHILD_FIRST ) as $ dir ) { ... | Remove directory recursive . |
236,970 | public static function scan ( $ path , $ mod = GLOB_ONLYDIR , $ returnRelative = false ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return false ; } $ pattern = rtrim ( $ path , '/' ) . '/*' ; $ entry = glob ( $ pattern , $ mod ) ; if ( $ returnRelative === true ) { foreach ( ... | Scan files in directory and return full or relative path |
236,971 | public static function recursiveChmod ( $ path , $ mod = 0777 ) { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! self :: exist ( $ path ) ) { return ; } $ dir = new \ DirectoryIterator ( $ path ) ; foreach ( $ dir as $ item ) { if ( $ item -> isDir ( ) || $ item -> isFile ( ) ) { chmod ( $ item -> getPathname (... | Change chmod recursive inside defined folder |
236,972 | public function getContent ( ) { $ json = new \ stdClass ( ) ; $ json -> isSuccess = $ this -> isSuccess ( ) ; $ json -> errorCode = $ this -> getErrorCode ( ) ; $ json -> errorMessage = $ this -> getErrorMessage ( ) ; $ json -> data = $ this -> content ; return $ json ; } | Over getContent response . Add specific content to the response . |
236,973 | final public function setErrorMessage ( $ message ) { $ this -> errorMessage = ( string ) $ message ; if ( empty ( $ this -> errorMessage ) ) { throw new \ RuntimeException ( 'Error message cannot be empty !' ) ; } return $ this ; } | Set error message . |
236,974 | public function appendContent ( $ key , $ value ) { if ( $ this -> content === null ) { $ this -> content = array ( ) ; } if ( ! is_array ( $ this -> content ) ) { throw new \ InvalidArgumentException ( 'Cannot append response content: Current content is not an array !' ) ; } $ this -> content [ ( string ) $ key ] = $ ... | Append content for the response . |
236,975 | public function get ( $ route_name ) { $ route = null ; if ( ! array_key_exists ( $ route_name , $ this -> routes ) ) echo "Router: error: the array key $route_name doesn't exists.<br />" ; else { $ route_infos = $ this -> routes [ $ route_name ] ; if ( $ route_controller = $ this -> instancy_controller ( $ route_infos... | returns the controller with route_name |
236,976 | public function check ( $ getPayload = false ) { try { $ payload = $ this -> checkOrFail ( ) ; } catch ( JwTException $ e ) { return false ; } return $ getPayload ? $ payload : true ; } | Check that the token is valid . |
236,977 | public function has ( string $ key ) : bool { foreach ( $ this -> repositories as $ repository ) { if ( $ repository -> has ( $ key ) ) { return true ; } } return false ; } | Check whether the repository contains a given key . |
236,978 | public function isValidResponse ( $ ha1 ) { if ( $ this -> opaque === NULL ) { return false ; } if ( ! SecurityUtil :: timingSafeEquals ( $ this -> auth -> getOpaque ( ) , $ this -> opaque ) ) { return false ; } $ args = [ $ ha1 , $ this -> nonce , $ this -> nc , $ this -> cnonce , $ this -> auth -> getQualityOfProtect... | Check if the response is valid using the given HA1 value . |
236,979 | public function addRoute ( string $ path , string $ controller , string $ action = 'index' , string $ method = Request :: METHOD_GET ) : self { $ endPoint = new RouteEndpoint ( $ this -> namespace , $ controller , $ action , $ method ) ; $ this -> routes [ ] = new Route ( $ path , $ endPoint ) ; return $ this ; } | Add a new route to the collection |
236,980 | public function defaultSpa ( $ request , $ match ) { $ name = Tenant_Service :: setting ( 'spa.default' , 'not-found' ) ; $ spa = Tenant_SPA :: getSpaByName ( $ name ) ; if ( ! isset ( $ spa ) ) { $ spa = Tenant_SpaService :: getNotfoundSpa ( ) ; } $ host = ( $ request -> https ? 'https://' : 'http://' ) . $ request ->... | Load default spa |
236,981 | public function defaultSpaRobotsTxt ( $ request , $ match ) { $ name = Tenant_Service :: setting ( 'spa.default' , 'not-found' ) ; $ spa = Tenant_SPA :: getSpaByName ( $ name ) ; if ( ! isset ( $ spa ) ) { $ spa = Tenant_SpaService :: getNotfoundSpa ( ) ; } $ resourcePath = $ spa -> getResourcePath ( 'robots.txt' ) ; $... | Load robots . txt of default spa |
236,982 | public function loadResource ( $ request , $ match ) { $ firstPart = $ match [ 'firstPart' ] ; $ remainPart = '' ; if ( array_key_exists ( 'remainPart' , $ match ) ) { $ remainPart = $ match [ 'remainPart' ] ; } $ spa = Tenant_SPA :: getSpaByName ( $ firstPart ) ; if ( isset ( $ spa ) ) { $ path = $ remainPart ; $ spaN... | Load a resource from SPA |
236,983 | private function findTenantResource ( $ path ) { $ q = new Pluf_SQL ( 'path=%s' , array ( $ path ) ) ; $ item = new Tenant_Resource ( ) ; $ item = $ item -> getList ( array ( 'filter' => $ q -> gen ( ) ) ) ; if ( isset ( $ item ) && $ item -> count ( ) == 1 ) { return $ item [ 0 ] ; } return null ; } | Finds tenant resource with path |
236,984 | public function transpile ( ) { $ this -> form = $ this -> transpiler -> instantiateFormObject ( ) ; $ fields = $ this -> transpiler -> findFields ( ) ; if ( ! is_array ( $ fields ) ) { throw new \ Exception ( "No fields found" ) ; } $ this -> form -> addFields ( $ fields ) ; $ this -> form -> populateFields ( ) ; $ th... | Convert a markup to a BaseForm objet |
236,985 | function ruleBefore ( $ date , $ error_message = null ) { if ( ! strtotime ( $ date ) ) { throw new \ Exception ( 'Incorrect date' ) ; } return $ this -> _rule ( 'before:' . $ date , $ error_message ) ; } | The field under validation must be a value preceding the given date . The dates will be passed into the PHP strtotime function . |
236,986 | function ruleBetween ( $ min , $ max , $ error_message = null ) { if ( ! is_numeric ( $ min ) ) { throw new \ Exception ( 'Incorrect parameter MIN in rule between' ) ; } if ( ! is_numeric ( $ max ) ) { throw new \ Exception ( 'Incorrect parameter MAX in rule between' ) ; } return $ this -> _rule ( 'between:' . $ min . ... | The field under validation must have a size between the given min and max . Strings numerics and files are evaluated in the same fashion as the size rule . |
236,987 | function ruleMin ( $ min , $ error_message = null ) { if ( ! is_numeric ( $ min ) ) { throw new \ Exception ( 'Incorrect parameter MIN in rule min' ) ; } return $ this -> _rule ( 'min:' . $ min , $ error_message ) ; } | The field under validation must have a minimum value . Strings numerics and files are evaluated in the same fashion as the size rule . |
236,988 | function ruleRequiredIf ( $ anotherfield , $ value , $ error_message = null ) { return $ this -> _rule ( 'required_if:' . $ anotherfield . ',' . $ value , $ error_message ) ; } | The field under validation must be present if the anotherfield field is equal to any value . |
236,989 | function ruleRequiredUnless ( $ anotherfield , $ value , $ error_message = null ) { return $ this -> _rule ( 'required_unless:' . $ anotherfield . ',' . $ value , $ error_message ) ; } | The field under validation must be present unless the anotherfield field is equal to any value . |
236,990 | function ruleRequiredWith ( $ anotherfields , $ error_message = null ) { if ( is_array ( $ anotherfields ) ) { $ anotherfields = implode ( ',' , $ anotherfields ) ; } return $ this -> _rule ( 'required_with:' . $ anotherfields , $ error_message ) ; } | The field under validation must be present only if any of the other specified fields are present . |
236,991 | function ruleRequiredWithout ( $ anotherfields , $ error_message = null ) { if ( is_array ( $ anotherfields ) ) { $ anotherfields = implode ( ',' , $ anotherfields ) ; } return $ this -> _rule ( 'required_without:' . $ anotherfields , $ error_message ) ; } | The field under validation must be present only when any of the other specified fields are not present . |
236,992 | function ruleRequiredWithoutAll ( $ anotherfields , $ error_message = null ) { if ( is_array ( $ anotherfields ) ) { $ anotherfields = implode ( ',' , $ anotherfields ) ; } return $ this -> _rule ( 'required_without_all:' . $ anotherfields , $ error_message ) ; } | The field under validation must be present only when all of the other specified fields are not present . |
236,993 | protected function copyAndNormalize ( ) { if ( $ this -> utcTimezone === null ) $ this -> utcTimezone = new DateTimeZone ( 'UTC' ) ; $ args = func_get_args ( ) ; foreach ( $ args as $ i => $ dt ) if ( $ dt instanceof DateTime ) { $ dt = clone $ dt ; $ dt -> setTimezone ( $ this -> utcTimezone ) ; $ args [ $ i ] = $ dt ... | Copies any number of DateTime objects and normalizes their timezones . |
236,994 | public function log ( $ level , $ message , array $ context = [ ] ) { if ( array_key_exists ( $ level , $ this -> logPrefixesPerLevel ) === false ) { throw new InvalidArgumentException ( 'Console method not recognised' ) ; } $ parsedMessage = $ this -> parseMessage ( $ message ) ; $ parsedMessage .= $ this -> parseCont... | Logs to an arbitrary log level . |
236,995 | private function parseMessage ( $ message ) { $ parsedMessage = null ; switch ( gettype ( $ message ) ) { case 'boolean' : case 'integer' : case 'double' : case 'string' : case 'NULL' : $ parsedMessage = ( string ) $ message ; break ; case 'object' : if ( method_exists ( $ message , '__toString' ) !== false ) { $ parse... | Parses the log message and returns as a useable string or Psr \ Log \ InvalidArgumentException if non parseable . |
236,996 | public function parse ( array $ classes ) { $ APIAnnotations = [ ] ; foreach ( $ classes as $ class ) { $ reflectionClass = new \ ReflectionClass ( $ class ) ; foreach ( $ reflectionClass -> getMethods ( ) as $ reflectionMethod ) { $ annotations = $ this -> getReader ( ) -> getMethodAnnotations ( $ reflectionMethod ) ;... | Parses the files provided by the SeekableIterator |
236,997 | protected static function extractType ( $ type ) { if ( substr ( $ type , - 2 ) === Connection :: PARAM_ARRAY ) { return substr ( $ type , 0 , strlen ( $ type ) - 2 ) ; } return false ; } | Extracts the fridge type from the expanded type . |
236,998 | public static function autoload ( ) { $ dir_base = realpath ( __DIR__ . '/../../../../' ) ; $ finder = new Finder ( ) ; $ finder -> files ( ) -> ignoreVCS ( true ) -> ignoreDotFiles ( false ) -> name ( 'service.yml' ) -> exclude ( 'Tests' ) -> exclude ( 'tests' ) -> in ( $ dir_base ) ; foreach ( $ finder as $ file ) { ... | Auto register services . |
236,999 | protected static function autoloadFile ( SplFileInfo $ file ) { $ yml = Yaml :: parse ( file_get_contents ( $ file -> getRealPath ( ) ) , true ) ; $ service = Arr :: get ( $ yml , 'micro-service' ) ; if ( is_null ( $ service ) ) { return ; } sbox ( ) -> add ( new MicroService ( $ service , $ yml ) ) ; } | Carregar arquivo . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.