idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
13,800 | public function AddGenericFile ( $ file_name , & $ content , $ subdir = "" ) { if ( $ subdir ) { $ subdir = trim ( $ subdir , "\\/" ) . "/" ; if ( ! file_exists ( $ this -> output_path . $ subdir ) ) \ Peg \ Lib \ Utilities \ FileSystem :: MakeDir ( $ this -> output_path . $ subdir , 0755 , true ) ; } $ output_file = $... | Adds or updates a generic file if neccessary . |
13,801 | static function dump ( $ value , int $ maxLevel = self :: DEFAULT_MAX_LEVEL , ? int $ maxStringLen = self :: DEFAULT_MAX_STRING_LENGTH , ? string $ encoding = null , int $ currentLevel = 1 ) : string { $ type = gettype ( $ value ) ; switch ( $ type ) { case 'array' : return self :: dumpArray ( $ value , $ maxLevel , $ ... | Dump a value |
13,802 | static function dumpString ( string $ string , ? int $ maxLength = null , ? string $ encoding = null , ? array $ quotes = null , ? string $ ellipsis = null ) : string { $ stringLength = $ encoding === null ? mb_strlen ( $ string ) : mb_strlen ( $ string , $ encoding ) ; $ tooLong = $ maxLength !== null && $ stringLengt... | Dump a string |
13,803 | static function dumpStringAsHex ( string $ string , int $ width = self :: DEFAULT_HEX_WIDTH ) : string { static $ from = '' ; static $ to = '' ; if ( $ from === '' ) { for ( $ i = 0 ; $ i <= 0xFF ; $ i ++ ) { $ from .= chr ( $ i ) ; $ to .= ( $ i >= 0x20 && $ i <= 0x7E ) ? chr ( $ i ) : '.' ; } } $ hex = str_split ( bi... | Dump a string in HEX format |
13,804 | static function getObjectProperties ( $ object , bool $ includeStatic = true ) : array { $ properties = [ ] ; try { $ filter = \ ReflectionProperty :: IS_PUBLIC | \ ReflectionProperty :: IS_PROTECTED | \ ReflectionProperty :: IS_PRIVATE ; $ parentFilter = \ ReflectionProperty :: IS_PRIVATE ; $ reflection = new \ Reflec... | Get all properties of the given object |
13,805 | public function createProjectByInput ( InputInterface $ input ) : Project { $ configFinder = new ConfigFinder ( ) ; $ configLoader = new ConfigLoader ( ) ; $ configPath = rtrim ( $ input -> getOption ( 'config' ) , DIRECTORY_SEPARATOR ) ; $ configValues = $ configLoader -> loadConfigValues ( $ configFinder -> findConfi... | Create project given an input instance . |
13,806 | protected function configureFormatter ( OutputInterface $ output ) { $ formatter = $ output -> getFormatter ( ) ; $ formatter -> setStyle ( 'header' , new OutputFormatterStyle ( 'green' ) ) ; $ formatter -> setStyle ( 'failheader' , new OutputFormatterStyle ( 'red' ) ) ; $ formatter -> setStyle ( 'body' , new OutputFor... | Configure formatter with Elcodi specific style . |
13,807 | public static function setup ( ) { if ( static :: $ setup === false ) { try { static :: create_container ( ) ; static :: init_config ( ) ; static :: init_routing ( ) ; static :: init_services ( ) ; static :: add_wordpress_globals ( ) ; $ loader = new Loader ( ) ; $ loader -> boot ( ) ; static :: register_providers ( ) ... | Setup Snap . |
13,808 | public static function init_config ( $ theme_root = null ) { if ( static :: $ setup === false ) { $ config = new Config ( ) ; if ( $ theme_root === null ) { $ config_cache_path = \ get_stylesheet_directory ( ) . '/cache/config/' . \ sha1 ( NONCE_SALT . 'theme' ) ; if ( WP_DEBUG === false && \ file_exists ( $ config_cac... | Create a config instance provide config directories and add to the container . |
13,809 | public static function register_providers ( ) { $ provider_instances = [ ] ; foreach ( static :: $ container -> get ( Config :: class ) -> get ( 'services.providers' ) as $ provider ) { try { $ provider = static :: $ container -> resolve ( $ provider ) ; $ provider -> register ( ) ; $ provider_instances [ ] = $ provide... | Registers any service providers defined in theme config . |
13,810 | private static function init_templating ( ) { if ( ! static :: $ container -> has ( Templating_Interface :: class ) ) { static :: $ container -> add_singleton ( \ Snap \ Templating \ Standard \ Standard_Strategy :: class , function ( ) { return new \ Snap \ Templating \ Standard \ Standard_Strategy ; } ) ; static :: $ ... | Add the templating definitions to the container . |
13,811 | private static function init_view ( ) { static :: $ container -> add_singleton ( View :: class , function ( Container $ hodl ) { return $ hodl -> resolve ( View :: class ) ; } ) ; static :: $ container -> alias ( View :: class , 'view' ) ; } | Add the View class ot the container . |
13,812 | private static function init_routing ( ) { static :: $ container -> add_singleton ( Router :: class , function ( ) { return new Router ( ) ; } ) ; static :: $ container -> add_singleton ( Request :: class , function ( ) { return new Request ( ) ; } ) ; static :: $ container -> add_singleton ( Response :: class , functi... | Add Snap routing request and validation services to the container . |
13,813 | public function getUrl ( $ model = null ) { if ( $ model === null ) { $ m = $ this -> commentFor [ $ this -> model ] ; $ model = $ this -> $ m ; } return $ model ? $ model -> url . '#c' . $ this -> id : '' ; } | Get Url for the model . By default model is a Post . |
13,814 | public function canBeAnswered ( ) { $ countInThread = Comment :: find ( ) -> where ( [ 'thread' => $ this -> thread , 'user_id' => Yii :: $ app -> user -> id ] ) -> count ( ) ; return ! Yii :: $ app -> user -> isGuest && $ this -> last && Yii :: $ app -> user -> identity -> group == User :: GROUP_COMMENTATOR && $ this ... | Comment can be answered if User is not a guest and this is the last comment in a thread and User is a commentator and last comment not belongs to User User begun the thread . |
13,815 | public function notifyResponsible ( $ event ) { $ from = [ Yii :: $ app -> params [ 'email' ] [ 'from' ] => 'not-reply' ] ; $ from [ $ this -> author -> email ] = $ this -> author -> name ; $ receiver = Yii :: $ app -> params [ 'email' ] [ 'receiver' ] [ 'comment' ] ; $ to = Yii :: $ app -> params [ 'email' ] [ 'to' ] ... | Send email for responsible person . |
13,816 | public function setStoragePath ( $ path ) { $ dir = pathinfo ( $ path , PATHINFO_DIRNAME ) ; $ name = pathinfo ( $ path , PATHINFO_BASENAME ) ; $ dir = realpath ( $ dir ) ; if ( $ dir === false ) { throw new Exceptions \ MetadataError ( 'Invalid path: "' . $ path . '"' ) ; } $ this -> metadataPath = $ dir . DIRECTORY_S... | Set the metadata storage path |
13,817 | public function setMetaParam ( Resource $ resource , $ name , $ value ) { if ( ! $ this -> getMetadata ( $ resource ) ) { return ; } $ this -> metadata [ $ resource -> getPath ( ) ] -> $ name = $ value ; $ this -> metadataChanged = true ; } | Set metadata parameter for the resource |
13,818 | public function getMetadata ( Resource $ resource , $ forceUpdate = false ) { if ( $ this -> metadata === null ) { $ this -> initMetadata ( ) ; } $ path = $ resource -> getPath ( ) ; if ( ! is_file ( $ path ) ) { return false ; } if ( ! $ forceUpdate && isset ( $ this -> metadata [ $ path ] ) ) { return $ this -> metad... | Get metadata for the resource |
13,819 | protected function initMetadata ( ) { if ( ! is_file ( $ this -> metadataPath ) ) { $ this -> metadata = [ ] ; return $ this -> metadata ; } $ metaRaw = file_get_contents ( $ this -> metadataPath ) ; if ( $ metaRaw === false ) { throw new Exceptions \ MetadataError ( 'Unable to read the metadata' ) ; } $ meta = json_de... | Get the files metadata |
13,820 | private static function getEndpoint ( $ config ) { if ( isset ( $ config [ 'mode' ] ) ) { switch ( strtoupper ( $ config [ 'mode' ] ) ) { case 'SANDBOX' : $ baseEndpoint = Constants :: STAGING_WSDL_ENDPOINT ; break ; case 'LIVE' : $ baseEndpoint = Constants :: PROD_WSDL_ENDPOINT ; break ; default : throw new Configurat... | Get base endpoint for SOAP WSDL service |
13,821 | protected function installLaranix ( ) { $ replaceAppFiles = [ '.stub' , '.php' ] ; $ parts = [ 'Controllers' => [ app_path ( 'Http' ) , true , false , $ replaceAppFiles ] , 'Requests' => [ app_path ( 'Http' ) , true , false , $ replaceAppFiles ] , 'themes' => [ resource_path ( ) , false , true , [ ] ] , 'views' => [ re... | Install Laranix components |
13,822 | protected function publishMailMarkdown ( ) { if ( ! $ this -> optionSet ( 'mail' ) ) { $ this -> info ( 'Skipping markdown mail (Laravel)' , OutputInterface :: VERBOSITY_VERBOSE ) ; return ; } if ( ! $ this -> confirmOverwrite ( 'mail templates' ) ) { return ; } $ this -> info ( 'Publishing markdown mail templates (Lar... | Publish Laravel mail markdown templates |
13,823 | protected function copyTemplates ( string $ srcDir , array $ files , string $ dstDir , array $ extReplace = [ ] , bool $ compile = false ) { foreach ( $ files as $ file ) { $ fullSrc = $ this -> getPath ( "{$srcDir}/{$file}" ) ; $ fullDst = "{$dstDir}/{$srcDir}/" . ( ! empty ( $ extReplace ) ? str_replace ( $ extReplac... | Copy template files and folders |
13,824 | protected function copyFile ( string $ src , string $ dst , bool $ compile ) { if ( is_file ( $ dst ) && ! $ this -> overwrite && ! $ this -> confirmOverwrite ) { $ this -> info ( "File exists and overwrite disabled, skipping {$dst}" , OutputInterface :: VERBOSITY_VERY_VERBOSE ) ; } if ( ! $ this -> confirmOverwrite ( ... | Copy file to location |
13,825 | protected function getFiles ( string $ relativeDir , array & $ filesystem = [ ] ) : array { $ fullDir = $ this -> getPath ( $ relativeDir ) ; $ dirIterator = new FilesystemIterator ( $ fullDir , FilesystemIterator :: SKIP_DOTS ) ; foreach ( $ dirIterator as $ info ) { if ( $ info -> isDir ( ) ) { $ this -> getFiles ( "... | Load files in templates directory |
13,826 | protected function optionSet ( string $ option ) : bool { return isset ( $ this -> allOptions [ $ option ] ) && $ this -> allOptions [ $ option ] === true || ( isset ( $ this -> allOptions [ 'all' ] ) && $ this -> allOptions [ 'all' ] === true && $ option !== 'overwrite' && $ option !== 'prompt' ) ; } | Check if option is set |
13,827 | public function getData ( $ key ) { if ( ! array_key_exists ( $ key , $ this -> data ) ) { throw new \ InvalidArgumentException ( sprintf ( "Can't find gluggi data with key '%s'." , $ key ) ) ; } return $ this -> data [ $ key ] ; } | Returns the user defined data |
13,828 | public function crop ( $ start , $ length = null ) { $ this -> setInternalValue ( mb_substr ( $ this -> getInternalValue ( ) , $ start , $ length , 'UTF-8' ) ) ; return $ this ; } | Crop the current internal value |
13,829 | public static function minFromTable ( array $ table ) { if ( ! is_array ( $ table ) ) { throw new \ InvalidArgumentException ( 'Function require the array,' . gettype ( $ table ) ) ; } if ( count ( $ table ) == 0 ) { throw new \ InvalidArgumentException ( 'Table is empty' ) ; } $ min = $ table [ 0 ] ; if ( count ( $ ta... | This function return the min of table . |
13,830 | public function addParameters ( array $ parameters ) : self { $ this -> parameters = ( array ) ConfigHelpers :: merge ( $ parameters , $ this -> parameters ) ; return $ this ; } | Adds new parameters . |
13,831 | public function loadComponents ( ComponentType $ type ) : array { $ path = "{$this->templatesDir}/{$type->getDirectory()}" ; if ( ! is_dir ( $ path ) || ! is_readable ( $ path ) ) { return [ ] ; } $ finder = new Finder ( ) ; $ files = $ finder -> files ( ) -> in ( $ path ) -> depth ( "== 0" ) -> name ( "*.html.twig" ) ... | Loads all components for the given type |
13,832 | public static function toMethod ( $ class , $ asArray = false ) { if ( is_string ( $ class ) ) { $ class = self :: split ( $ class ) ; } $ method = array_pop ( $ class ) ; $ classname = implode ( "\\" , $ class ) ; return ( $ asArray ) ? [ $ classname , $ method ] : "$classname::$method" ; } | Convert a string into a namespaced method name |
13,833 | public static function fromContents ( string $ contents ) : string { $ class = "" ; $ namespace = "" ; $ tokens = token_get_all ( $ contents ) ; $ len = count ( $ tokens ) ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { if ( $ tokens [ $ i ] [ 0 ] === T_NAMESPACE ) { for ( $ j = $ i + 1 ; $ j < $ len ; $ j ++ ) { if ( $ tok... | Get a namespaced classname from a string of php |
13,834 | public static function add ( $ library ) { $ connected = Application :: get ( 'flag.global.library.' . $ library . '.connected' ) ; if ( ! $ connected ) { Factory :: submodule ( 'flag.global.library.' . $ library . '.submodule' ) -> add ( ) ; Application :: set ( 'flag.global.library.' . $ library . '.connected' , true... | Add library to the application |
13,835 | public function warning ( string $ message ) { if ( $ this -> status == 'ok' ) { $ this -> status = 'warning' ; } $ this -> warnings [ ] = $ message ; } | Add warning message |
13,836 | public function toArray ( ) : array { if ( ! empty ( $ this -> warnings ) ) { $ this -> status = 'warning' ; } elseif ( ! empty ( $ this -> errors ) ) { $ this -> status = 'error' ; } return [ 'status' => $ this -> status , 'errors' => array_merge ( array_map ( function ( $ x ) { return [ 'severity' => 'error' , 'messa... | Convert check result to array |
13,837 | public static function formatIniParamSize ( string $ res ) : int { $ res = trim ( $ res ) ; $ measure = strtolower ( $ res [ strlen ( $ res ) - 1 ] ) ; $ res = ( int ) $ res ; switch ( $ measure ) { case 'g' : $ res *= 1024 ; case 'm' : $ res *= 1024 ; case 'k' : $ res *= 1024 ; } return $ res ; } | Get size from formatted ini params string |
13,838 | public static function formatDataSizeFromBytes ( int $ b ) : string { $ unit = '' ; foreach ( [ 'B' , 'KB' , 'MB' , 'GB' , 'TB' ] as $ unit ) { if ( $ b < 1024 ) break ; $ b = round ( $ b / 1024 , 1 ) ; } return $ b . ' ' . $ unit ; } | Converts file size from bytes to readable format |
13,839 | public static function cutLongStrings ( string $ sentence , int $ max_length = 50 , string $ separator = ' ' , string $ postfix = '...' ) : string { if ( mb_strlen ( $ sentence , 'utf-8' ) <= $ max_length ) { return $ sentence ; } $ words = mb_split ( "[" . $ separator . "]+" , $ sentence ) ; $ res = '' ; $ count_of_wo... | Cuts long sentences so only first few words are returned |
13,840 | public static function replaceLinksInTextsWithHrefs ( string $ text ) : string { $ text = preg_replace ( '#(script|about|applet|activex|chrome):#is' , "\\1:" , $ text ) ; $ ret = ' ' . $ text ; $ ret = preg_replace ( "#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is" , "\\1<a href=\"\\2\" target=\"_blank\" rel=\"nofo... | Returns same text with changed link word to full hrefs |
13,841 | public function getResponseMessages ( ) : array { $ responses = array ( ) ; foreach ( $ this -> objects as $ object ) { $ responses [ ] = $ object -> respond ( ) ; } $ messages = array ( ) ; foreach ( self :: responder ( $ responses ) as $ message ) { $ messages [ ] = $ message ; } return $ messages ; } | Get an array of response messages from all GroupObjects loaded |
13,842 | private function itterator ( array $ data ) { foreach ( $ data as $ item ) { if ( self :: areArrayKeysInt ( $ item ) ) { $ this -> itterator ( $ item ) ; } $ object = self :: identifyObject ( $ item ) ; yield $ this -> { "parse$object" } ( $ item ) ; } } | Generator function to itterate over an array from a file . Individual items are identified and given to the appropriate parser . The resulting object returned by the parser is yielded . |
13,843 | private static function identifyObject ( array $ item ) : string { if ( isset ( $ item [ 'group' ] ) and isset ( $ item [ 'members' ] ) and is_array ( $ item [ 'members' ] ) and ! isset ( $ item [ 'option' ] ) ) { return "Group" ; } elseif ( isset ( $ item [ 'option' ] ) and ! isset ( $ item [ 'members' ] ) and ! isset... | Identify the object parser that a particular item should be handed to |
13,844 | private function parseGroup ( array $ item ) : Group { $ type = strtoupper ( $ item [ 'group' ] ) ; if ( ! in_array ( $ type , self :: GROUP_TYPES ) ) { throw new OptionLoaderException ( "Unrecognised group type $type" , $ item ) ; } $ groupClass = self :: GROUP_NAMESPACE . "${type}Group" ; $ group = new $ groupClass (... | Parse a group from file data structure |
13,845 | private function parseOption ( array $ item ) : Option { $ name = $ item [ 'option' ] ; $ characteristic = $ item [ 'characteristic' ] ?? null ; if ( isset ( $ characteristic ) ) { $ characteristic = self :: optionCharacteristic ( $ characteristic ) ; } $ type = $ item [ 'type' ] ?? null ; $ default = $ item [ 'default... | Parse an option from file data structure |
13,846 | public function custom_template_locator ( $ post_templates , $ wp_theme , $ post , $ post_type ) { $ path = \ get_stylesheet_directory ( ) . '/' . Config :: get ( 'theme.templates_directory' ) . '/views/post-templates/' ; $ templates = \ scandir ( $ path ) ; if ( ! empty ( $ templates ) ) { foreach ( $ templates as $ t... | Scans the templates folder and adds any templates found to the global template array . |
13,847 | public function post_template_routing ( $ template_path ) { $ routes_file = \ get_template_directory ( ) . '/public/routes.php' ; if ( \ is_child_theme ( ) ) { $ routes_file = \ locate_template ( 'public/routes.php' ) ; } if ( '' !== $ routes_file ) { return $ routes_file ; } return $ template_path ; } | Ensure post template requests get routed to our main front controller instead of some random file . |
13,848 | private function createFile ( ) { $ cacheMethod = \ PHPExcel_CachedObjectStorageFactory :: cache_to_phpTemp ; $ cacheSettings = array ( 'memoryCacheSize' => '128MB' ) ; \ PHPExcel_Settings :: setCacheStorageMethod ( $ cacheMethod , $ cacheSettings ) ; return new \ PHPExcel ( ) ; } | Create the PHPExcel instance to work in |
13,849 | private function initWorksheets ( ) { foreach ( $ this -> file -> getAllSheets ( ) as $ index => $ worksheet ) { $ this -> sheets [ $ index ] = new Sheet ( $ worksheet ) ; } return $ this ; } | Initialize the worksheets by creating a Sheet object for all of them |
13,850 | public function writeRow ( array $ data = [ ] , $ sheetIndex = 0 , $ finalize = true ) { $ sheet = $ this -> sheets [ $ sheetIndex ] ; return $ sheet -> writeRow ( $ data , $ finalize ) ; } | Write data to a row |
13,851 | final public function generateFile ( $ filename , $ format = 'Excel2007' , $ disconnect = true ) { $ this -> formatFile ( ) ; $ this -> file -> setActiveSheetIndex ( 0 ) ; list ( $ path , $ filename ) = $ this -> writeFileToTmp ( $ filename , $ format , $ disconnect ) ; $ this -> setGenerated ( true ) ; return array ( ... | Generate the file return its location |
13,852 | public function outputFile ( $ fileName = null , $ format = 'Excel2007' , $ disconnect = true ) { if ( ! $ this -> generated ) { $ this -> generateFile ( $ fileName , $ format , $ disconnect ) ; } if ( null === $ fileName ) { $ fileName = $ this -> fileName ; } $ handler = fopen ( $ this -> filePath , 'r' ) ; header ( ... | Output a file to the browser |
13,853 | private function writeFileToTmp ( $ filename , $ format = 'Excel2007' , $ disconnect = true ) { $ path = sprintf ( '%s/%s' , $ this -> tempPath , $ filename ) ; $ objWriter = \ PHPExcel_IOFactory :: createWriter ( $ this -> file , $ format ) ; $ objWriter -> save ( $ path ) ; if ( $ disconnect ) { $ this -> file -> dis... | Create excel file and store in tmp dir |
13,854 | public function getSheet ( $ sheetIndex = 0 ) { if ( ! isset ( $ this -> sheets [ $ sheetIndex ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'No sheet with index %d defined' , $ sheetIndex ) ) ; } return $ this -> sheets [ $ sheetIndex ] ; } | Get a specific sheet by sheetIndex |
13,855 | public function setWorksheetTitle ( $ title , $ sheetIndex = 0 ) { if ( ! isset ( $ this -> sheets [ $ sheetIndex ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'No sheet with index %d defined' , $ sheetIndex ) ) ; } $ this -> sheets [ $ sheetIndex ] -> getWorksheet ( ) -> setTitle ( $ title ) ; return $ this... | Set the title for a certain worksheet . Defaults to the first sheet |
13,856 | protected function getCliParams ( ) { if ( empty ( $ _SERVER [ 'argv' ] ) ) { return [ ] ; } $ params = preg_grep ( '/^\-\-zdebug:/' , $ _SERVER [ 'argv' ] ) ; if ( empty ( $ params ) ) { return [ ] ; } return array_map ( function ( $ in ) { return str_replace ( '--zdebug:' , '' , $ in ) ; } , $ params ) ; } | Get CLI parameters |
13,857 | public function save ( ) { if ( $ this -> persistent ) { $ action = $ this -> { 'update' } ; $ action -> directCall ( $ this -> attrsForApi ( $ action ) ) ; } else { $ action = $ this -> { 'create' } ; $ ret = new Response ( $ action , $ action -> directCall ( $ this -> attrsForApi ( $ action ) ) ) ; if ( $ ret -> isOk... | Create the resource object if it isn t persistent update it if it is . |
13,858 | protected function attrsForApi ( $ action ) { $ ret = array ( ) ; $ desc = $ this -> description -> actions -> { $ action } -> input -> parameters ; foreach ( $ this -> attrs as $ k => $ v ) { if ( ! isSet ( $ desc -> { $ k } ) ) continue ; $ param = $ desc -> { $ k } ; switch ( $ param -> type ) { case 'Resource' : $ ... | Returns an array of parameters ready to be sent to the API . |
13,859 | protected function defineStubAttrs ( ) { $ params = $ this -> description -> actions -> { $ this -> action -> name ( ) } -> input -> parameters ; foreach ( $ params as $ name => $ desc ) { switch ( $ desc -> type ) { case 'Resource' : $ c = new \ stdClass ( ) ; $ c -> { $ desc -> value_id } = null ; $ c -> { $ desc -> ... | Create initial - NULL - resource object instance parameters . |
13,860 | function add ( $ value ) { if ( ! \ in_array ( $ value , $ this -> data , true ) ) { $ this -> data [ ] = $ value ; } return $ this ; } | Adds a value to the Set . |
13,861 | function delete ( $ value ) { $ key = \ array_search ( $ value , $ this -> data , true ) ; if ( $ key !== false ) { unset ( $ this -> data [ $ key ] ) ; } return $ this ; } | Deletes a value from the Set . |
13,862 | public function getComments ( $ offset = 0 ) { $ rows = Yii :: $ app -> db -> createCommand ( 'SELECT DISTINCT thread ' . 'FROM comment ' . 'WHERE parent_id=:parent_id AND model=:model AND status=:status ' . 'ORDER BY thread DESC ' . 'LIMIT ' . Yii :: $ app -> params [ 'commentsPerPage' ] . ' OFFSET ' . $ offset ) -> b... | Get LIMITed comments with OFFSET for selected model . |
13,863 | public function getCommentCount ( ) { return count ( Comment :: findAll ( [ 'parent_id' => $ this -> id , 'model' => self :: COMMENT_FOR , 'status' => Comment :: STATUS_APPROVED ] ) ) ; } | Get count of comments for selected model . |
13,864 | public function addComment ( $ comment ) { if ( Yii :: $ app -> params [ 'commentNeedApproval' ] ) $ comment -> status = Comment :: STATUS_PENDING ; else $ comment -> status = Comment :: STATUS_APPROVED ; $ comment -> model = self :: COMMENT_FOR ; $ comment -> parent_id = $ this -> id ; $ comment -> user_id = \ Yii :: ... | Adds a new comment for the model . |
13,865 | public function addConfigReader ( Config \ ReaderInterface $ reader ) { $ id = $ reader -> getId ( ) ; if ( isset ( $ this -> configReaders [ $ id ] ) ) { throw new Exceptions \ InvalidConfig ( 'Configuration reader with ID "' . $ id . '" already exists' ) ; } $ this -> configReaders [ ] = $ reader ; foreach ( $ reader... | Add configuration reader |
13,866 | public function load ( $ config ) { if ( $ this -> configsDir === null ) { new Exceptions \ ConfiguratorError ( 'Directory of configuration files did not been set' ) ; } $ file = $ this -> configsDir -> getFile ( $ config ) ; $ this -> addConfigReader ( $ this -> initReader ( $ file ) ) ; return $ this ; } | Load configuration file |
13,867 | protected function initReader ( FileInterface $ file ) { $ extension = $ file -> getExtension ( ) ; if ( $ extension === 'xml' ) { return new Config \ XmlReader ( $ file ) ; } throw new Exceptions \ InvalidConfig ( 'Unknown type of configuration "' . $ extension . '"' ) ; } | Load reader by config file |
13,868 | protected function applyParameters ( stdClass $ definitions ) { $ parameters = $ this -> processArguments ( $ definitions ) ; $ config = $ this -> container -> getParametersConfig ( ) ; foreach ( $ parameters as $ name => $ value ) { $ config -> set ( $ name , $ value ) ; } } | Apply parameters to container |
13,869 | protected function applyServices ( stdClass $ config ) { foreach ( $ config as $ id => $ definitionConf ) { if ( ! isset ( $ definitionConf -> type ) ) { throw new Exceptions \ InvalidConfig ( 'Service definition must contain a "type" property"' ) ; } if ( $ definitionConf -> type === 'class' ) { if ( ! isset ( $ defin... | Apply services config to container |
13,870 | protected function applyInitializers ( stdClass $ config ) { foreach ( $ config as $ id => $ definitionConf ) { if ( ! isset ( $ definitionConf -> type ) ) { throw new Exceptions \ InvalidConfig ( 'Service definition must contain a "type" property"' ) ; } if ( $ definitionConf -> type === 'namespace' ) { if ( ! isset (... | Apply initializers config to container |
13,871 | protected function processArgumentValue ( stdClass $ argument ) { if ( ! isset ( $ argument -> value ) ) { throw new Exceptions \ InvalidConfig ( 'Argument of type "value" must contain a "value" property' ) ; } if ( is_array ( $ argument -> value ) ) { return $ this -> processArguments ( $ argument -> value ) ; } retur... | Process argument of the type value |
13,872 | protected function mergeConfigs ( array $ configs ) { $ result = new stdClass ( ) ; $ result -> parameters = new stdClass ( ) ; $ result -> services = new stdClass ( ) ; $ result -> initializers = new stdClass ( ) ; foreach ( $ configs as $ config ) { $ this -> mergeConfigsPart ( $ config -> getParameters ( ) , $ resul... | Merge configs into one |
13,873 | protected function mergeConfigsPart ( stdClass $ config , stdClass $ destination ) { foreach ( $ config as $ id => $ value ) { if ( ! $ this -> override && isset ( $ destination -> $ id ) ) { throw new Exceptions \ ServiceOverride ( 'ID "' . $ id . '" is already been set and cannot be overridden' ) ; } $ destination ->... | Merge part of config |
13,874 | protected function compile ( ) { $ buttons = new Helper \ Buttons ( ) ; $ buttons -> loadFromFieldset ( $ this -> buttons ) ; $ buttons -> buttonStyle = $ this -> buttonStyle ; $ this -> Template -> buttons = $ buttons ; } | compile the button toolbar |
13,875 | public function setDefaults ( array $ defaults ) : self { foreach ( ( array ) $ defaults as $ key => $ value ) { if ( isset ( $ this -> defaults [ $ key ] ) ) { $ this -> defaults [ $ key ] = $ value ; } else { throw new Exception ( 'Invalid route default' , Exception :: HTTP_INTERNAL_SERVER_ERROR ) ; } } return $ this... | Set route defaults |
13,876 | private function isAllowed ( RequestInterface $ request , array $ route ) : bool { $ allowed = true ; if ( false === empty ( $ route [ 'methods' ] ) ) { $ allowed = in_array ( $ request -> getMethod ( ) , ( array ) $ route [ 'methods' ] ) ; } return $ allowed ; } | Whether request method is allowed for given route |
13,877 | private function isMatching ( RequestInterface $ request , & $ route ) : int { $ match = - 1 ; $ pattern = str_replace ( '/' , '\/' , trim ( $ route [ 'pattern' ] , '/' ) ) ; $ pattern = str_replace ( array_keys ( self :: $ expressions ) , array_values ( self :: $ expressions ) , $ pattern ) ; if ( preg_match ( '/^' . ... | Match request against given route |
13,878 | private function overlay ( array $ route ) : array { $ target = $ this -> defaults ; foreach ( $ route [ 'route' ] [ 'target' ] as $ key => $ value ) { $ target [ $ key ] = $ value ; } return $ target ; } | Apply defaults to actual route |
13,879 | private function route ( RequestInterface $ request ) : ? Route { $ routes = $ this -> match ( $ request ) ; if ( empty ( $ routes ) ) { throw new Exception ( 'No route found' , Exception :: HTTP_NOT_FOUND ) ; } $ route = $ this -> guard ( $ request , $ routes ) ; if ( empty ( $ route ) ) { throw new Exception ( 'Metho... | Create route from given request |
13,880 | public static function all ( ) { global $ wpdb ; $ dbResults = $ wpdb -> get_results ( 'SELECT * FROM ' . static :: getTableName ( ) ) ; $ result = [ ] ; $ model = get_called_class ( ) ; foreach ( $ dbResults as $ dbResult ) { $ modelObject = new $ model ( ) ; foreach ( self :: $ columns as $ column ) { $ modelObject -... | Return all objects |
13,881 | public static function find ( $ ID = 0 ) { if ( empty ( $ ID ) || ! is_numeric ( $ ID ) || $ ID <= 0 ) { return null ; } global $ wpdb ; $ calledClass = get_called_class ( ) ; if ( 0 === strpos ( $ calledClass , 'Knob\\' ) ) { $ calledClass = substr ( $ calledClass , strpos ( $ calledClass , '\\' ) + 1 ) ; } $ sql = 'S... | Search and return the Object across his ID |
13,882 | public static function findBy ( $ criteria = [ ] , $ single = false ) { global $ wpdb ; $ return = [ ] ; $ query = static :: getQueryByCriteria ( $ criteria ) ; $ dbResults = $ wpdb -> get_results ( $ query ) ; if ( $ single && isset ( $ dbResults [ 0 ] ) ) { return static :: getModelFromDBObject ( $ dbResults [ 0 ] ) ... | Get all elements from DB who s contain the same criteria . |
13,883 | private static function getModelFromDBObject ( $ dbObject ) { $ modelName = get_called_class ( ) ; $ object = new $ modelName ( ) ; foreach ( $ dbObject as $ column => $ val ) { $ object -> $ column = $ val ; } return $ object ; } | Mount the ModelBase using the data from the DB . |
13,884 | public function getByUser ( int $ id , int $ scopes = self :: DEFAULT , int $ limit = 15 ) : LengthAwarePaginator { $ query = $ this -> getModel ( ) -> newQuery ( ) -> where ( 'user_id' , $ id ) ; return $ this -> getScopes ( $ query , $ scopes ) -> paginate ( $ limit ) ; } | Get cages for user |
13,885 | public function getByArea ( string $ area , int $ scopes = self :: DEFAULT , int $ limit = 15 ) : LengthAwarePaginator { $ query = $ this -> getModel ( ) -> newQuery ( ) -> where ( 'area' , $ area ) ; return $ this -> getScopes ( $ query , $ scopes ) -> paginate ( $ limit ) ; } | Get cages for area |
13,886 | public function getByAttributes ( array $ attributes , int $ scopes = self :: DEFAULT , int $ limit = 15 ) : LengthAwarePaginator { if ( empty ( $ attributes ) ) { return null ; } $ query = $ this -> getModel ( ) -> newQuery ( ) ; foreach ( $ attributes as $ key => $ value ) { $ query -> where ( $ key , $ value ) ; } r... | Get cages by attributes |
13,887 | public static function updateDatabase ( ) { FileSystem :: mkDir ( DIR_TEMP . 'GeoIPCountryCSV' ) ; $ file_to_extract = DIR_TEMP . 'GeoIPCountryCSV/GeoIPCountryCSV.zip' ; if ( ! file_exists ( $ file_to_extract ) || filemtime ( $ file_to_extract ) < NOW - 86400 ) { $ f = @ file_get_contents ( 'http://geolite.maxmind.com/... | Updates values in DB from fetched file |
13,888 | private function canProcess ( $ saleId ) { $ result = false ; $ entity = $ this -> daoReg -> getById ( $ saleId ) ; if ( $ entity ) { $ state = $ entity -> getState ( ) ; $ result = ( $ state == ERegistry :: STATE_PENDING ) ; } return $ result ; } | More than one invoice can relate for one sale order . We should not pay bonus twice ore more . |
13,889 | public function newCollection ( array $ models = [ ] ) { if ( app ( config ( 'auth.providers.users.model' ) ) -> jumpGateCollections ) { return new EloquentCollection ( $ models ) ; } return parent :: newCollection ( $ models ) ; } | Use the custom collection that allows tapping . |
13,890 | public static function paidAmount ( $ request , $ match ) { $ model = new Bank_Receipt ( ) ; $ params = array ( 'select' => 'SUM(amount) AS amount' , 'filter' => array ( 'payRef IS NOT NULL' , 'payMeta IS NOT NULL' ) ) ; $ result = $ model -> getList ( $ params ) ; return $ result [ 0 ] -> amount ; } | Total amount of all paid receipts |
13,891 | private function parseItem ( ) { $ subparser = new StringValue ( $ this -> parser , ( $ this -> level + 1 ) ) ; $ subparser -> parse ( ) ; $ key = $ subparser -> getValue ( ) ; $ this -> debug ( 'key: ' . var_export ( $ key , true ) ) ; if ( $ this -> tokenIs ( T_DOUBLE_ARROW ) ) { if ( $ key === null ) { $ this -> bai... | Parse an array value . |
13,892 | private function parseValue ( ) { $ this -> getNextToken ( ) ; if ( $ this -> tokenIs ( T_ARRAY ) || $ this -> tokenIs ( '[' ) ) { $ this -> debug ( 'Sub array with key.' ) ; $ subparser = new ArrayParser ( $ this -> parser , ( $ this -> level + 1 ) ) ; $ subparser -> parse ( ) ; } else { $ this -> debug ( 'String item... | Parse the value portion of a key = > value array element . |
13,893 | protected function createModel ( $ data ) { $ modelClass = $ this -> getModel ( ) ; $ model = $ modelClass :: factory ( $ data ) ; if ( $ this -> hasDatagate ( ) ) { $ model -> setDatagate ( $ this -> getDatagate ( ) ) ; } if ( $ this -> hasLocator ( ) ) { $ model -> setLocator ( $ this -> getLocator ( ) ) ; } return $... | Create a model |
13,894 | public function toArray ( $ recursively = false ) { if ( $ recursively ) { return iterator_to_array ( $ this -> _iterator ) ; } $ models = [ ] ; foreach ( $ this -> _iterator as $ data ) { $ models [ ] = $ this -> createModel ( $ data ) ; } return $ models ; } | Get an iterator s data as an array |
13,895 | public function toCollection ( ) { $ data = iterator_to_array ( $ this -> _iterator ) ; $ model = $ this -> getModel ( ) ; $ collection = new Collection ( $ data , $ model ) ; if ( $ this -> hasDatagate ( ) ) { $ collection -> setDatagate ( $ this -> getDatagate ( ) ) ; } if ( $ this -> hasLocator ( ) ) { $ collection ... | Get an iterator s data as Collection |
13,896 | public function dump ( $ recursion = 4 ) { if ( $ this -> hasLocator ( ) && $ this -> getLocator ( ) -> has ( 'modelsDumpDecorator' ) ) { $ decorator = $ this -> getLocator ( ) -> get ( 'modelsDumpDecorator' ) ; } else { throw new Exception ( 'Dump\'s decorator wasn\'t supplied' ) ; } return $ decorator -> dump ( $ thi... | Get the dump of the iterator s condition |
13,897 | public static function can ( $ action , $ object = null , $ message = null ) { if ( ! static :: getAuthorizer ( ) -> can ( $ action , $ object ) ) { throw new Exception ( $ message ? : self :: DEFAULT_MSG , 112 ) ; } return true ; } | Verify if the current user is allowed to make an action |
13,898 | public function setup ( $ force = false ) { if ( ! $ force && $ this -> description ) return ; $ this -> changeDescription ( $ this -> fetchDescription ( ) ) ; } | Fetch the API description if it isn t fetched yet . |
13,899 | public function logout ( ) { $ this -> authProvider -> logout ( ) ; $ this -> authProvider = new Client \ Authentication \ NoAuth ( $ this , array ( ) , array ( ) ) ; $ this -> changeDescription ( NULL ) ; } | Logout the authenticated user and destroy the authentication provider . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.