idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
227,700 | public function findAndInstallThemes ( ) : array { $ theme = new Theme ( ) ; $ directories = $ this -> filesystem -> directories ( $ theme -> getThemesDirectory ( ) ) ; $ themes = [ ] ; if ( is_array ( $ directories ) ) { foreach ( $ directories as $ directory ) { $ themeName = basename ( $ directory ) ; $ themes [ ] =... | Create a cache of the themes which are available on the filesystem . |
227,701 | public function getInstalledThemes ( ) : array { $ installed = $ this -> cache -> get ( $ this -> cacheKey ) ; if ( $ installed !== null ) { return $ installed ; } return $ this -> findAndInstallThemes ( ) ; } | Retrieves the installed themes from the cache . |
227,702 | public function createFromBlob ( Request $ request , Site $ site ) : array { $ this -> authorize ( 'uploadAssets' , $ site ) ; $ file = $ request -> file ( 'file' ) ; $ error = $ this -> validateFile ( $ file ) ; if ( $ error !== true ) { return [ ] ; } $ description = trans ( 'boomcms::asset.automatic-upload-descripti... | Controller for handling a single file upload from TinyMCE . |
227,703 | public function download ( Asset $ asset ) { return Response :: file ( AssetFacade :: path ( $ asset ) , [ 'Content-Type' => $ asset -> getMimetype ( ) , 'Content-Disposition' => 'download; filename="' . $ asset -> getOriginalFilename ( ) . '"' , ] ) ; } | Download the given asset . |
227,704 | public function embed ( Request $ request , Asset $ asset ) : View { $ viewPrefix = 'boomcms::assets.embed.' ; $ assetType = strtolower ( class_basename ( $ asset -> getType ( ) ) ) ; $ viewName = $ viewPrefix . $ assetType ; if ( ! view ( ) -> exists ( $ viewName ) ) { $ viewName = $ viewPrefix . 'default' ; } return ... | Returns the HTML to embed the given asset . |
227,705 | protected function getXmlAttrs ( ) { if ( $ this -> xmlAttrs === null ) { $ xml = simplexml_load_file ( $ this -> file -> getPathname ( ) ) ; $ this -> xmlAttrs = $ xml -> attributes ( ) ; } return $ this -> xmlAttrs ; } | Reads the SVG file and returns the XML attributes as an object . |
227,706 | public function output ( $ filename , $ input ) { $ env = array ( 'NODE_PATH' => $ this -> _settings [ 'node_path' ] ) ; $ tmpfile = tempnam ( sys_get_temp_dir ( ) , 'miniasset_css_compressor' ) ; $ this -> generateScript ( $ tmpfile , $ input ) ; $ cmd = $ this -> _settings [ 'node' ] . ' ' . $ tmpfile ; return $ this... | Run cleancss against the output and compress it . |
227,707 | protected function generateScript ( $ file , $ input ) { $ script = <<<JSvar csscompressor = require('css-compressor');var util = require('util');var source = %s;util.print(csscompressor.cssmin(source));process.exit(0);JS ; file_put_contents ( $ file , sprintf ( $ script , json_encode ( $ input ) ) ) ; } | Generates a small bit of Javascript code to invoke cleancss with . |
227,708 | public static function extractImports ( $ css ) { $ imports = [ ] ; preg_match_all ( static :: IMPORT_PATTERN , $ css , $ matches , PREG_SET_ORDER ) ; if ( empty ( $ matches ) ) { return $ imports ; } foreach ( $ matches as $ match ) { $ url = empty ( $ match [ 2 ] ) ? $ match [ 4 ] : $ match [ 2 ] ; $ imports [ ] = $ ... | Extract the urls in import directives . |
227,709 | protected function readMetadata ( ) : array { try { $ phpWord = IOFactory :: load ( $ this -> file -> getPathname ( ) ) ; $ docinfo = $ phpWord -> getDocInfo ( ) ; $ attrs = [ 'creator' => $ docinfo -> getCreator ( ) , 'created' => $ docinfo -> getCreated ( ) , 'lastModifiedBy' => $ docinfo -> getLastModifiedBy ( ) , '... | Retrieves metadata from the file and turns it into an array . |
227,710 | public function getTime ( ) { if ( ! $ this -> isHistory ( ) ) { return new DateTime ( 'now' ) ; } $ timestamp = $ this -> session -> get ( $ this -> timePersistenceKey , time ( ) ) ; return ( new DateTime ( ) ) -> setTimestamp ( $ timestamp ) ; } | Get the time to view pages at . |
227,711 | public function setTime ( DateTime $ time = null ) { $ timestamp = $ time ? $ time -> getTimestamp ( ) : null ; $ this -> session -> put ( $ this -> timePersistenceKey , $ timestamp ) ; if ( $ time ) { $ this -> setState ( static :: HISTORY ) ; } return $ this ; } | Set a time at which to view pages at . |
227,712 | public static function filesize ( $ bytes ) { $ precision = ( ( $ bytes % 1024 ) === 0 || $ bytes <= 1024 ) ? 0 : 1 ; $ formatter = new ByteSize \ Formatter \ Binary ( ) ; $ formatter -> setPrecision ( $ precision ) ; return $ formatter -> format ( $ bytes ) ; } | Turn a number of bytes into a human friendly filesize . |
227,713 | public static function nl2paragraph ( $ text ) { $ paragraphs = explode ( "\n" , $ text ) ; foreach ( $ paragraphs as & $ paragraph ) { $ paragraph = "<p>$paragraph</p>" ; } return implode ( '' , $ paragraphs ) ; } | Adds paragraph HTML tags to text treating each new line as a paragraph break . |
227,714 | public static function unique ( $ initial , Closure $ closure ) { $ append = 0 ; do { $ string = ( $ append > 0 ) ? ( $ initial . $ append ) : $ initial ; $ append ++ ; } while ( $ closure ( $ string ) === false ) ; return $ string ; } | Make a string unique . |
227,715 | public function getToolbar ( EditorObject $ editor , Request $ request ) { $ page = PageFacade :: find ( $ request -> input ( 'page_id' ) ) ; View :: share ( [ 'page' => $ page , 'editor' => $ editor , 'auth' => auth ( ) , 'person' => auth ( ) -> user ( ) , ] ) ; if ( $ editor -> isHistory ( ) ) { return view ( 'boomcm... | Displays the CMS interface with buttons for add page settings etc . Called from an iframe when logged into the CMS . |
227,716 | public function creating ( Model $ model ) { $ model -> created_at = time ( ) ; $ model -> created_by = $ this -> guard -> check ( ) ? $ this -> guard -> user ( ) -> getId ( ) : null ; } | Set created_at and created_by on the model prior to creation . |
227,717 | public function getStatus ( Page $ page ) { $ this -> authorize ( 'edit' , $ page ) ; return view ( "$this->viewPrefix.status" , [ 'page' => $ page , 'version' => $ page -> getCurrentVersion ( ) , 'auth' => auth ( ) , ] ) ; } | Show the current status of the page . |
227,718 | public function getTemplate ( Page $ page ) { $ this -> authorize ( 'editTemplate' , $ page ) ; return view ( "$this->viewPrefix.template" , [ 'current' => $ page -> getTemplate ( ) , 'templates' => TemplateFacade :: findValid ( ) , ] ) ; } | Show a form to change the template of the page . |
227,719 | public function requestApproval ( Page $ page ) { $ this -> authorize ( 'edit' , $ page ) ; $ page -> markUpdatesAsPendingApproval ( ) ; Event :: fire ( new Events \ PageApprovalRequested ( $ page , auth ( ) -> user ( ) ) ) ; return $ page -> getCurrentVersion ( ) -> getStatus ( ) ; } | Mark the page as requiring approval . |
227,720 | public function postEmbargo ( Request $ request , Page $ page ) { $ this -> authorize ( 'publish' , $ page ) ; $ embargoedUntil = new DateTime ( '@' . time ( ) ) ; if ( $ time = $ request -> input ( 'embargoed_until' ) ) { $ timestamp = strtotime ( $ time ) ; $ embargoedUntil -> setTimestamp ( $ timestamp ) ; } $ page ... | Set an embargo time for the current drafts . |
227,721 | public function postTemplate ( Page $ page , Template $ template ) { $ this -> authorize ( 'editTemplate' , $ page ) ; $ page -> setTemplate ( $ template ) ; Event :: fire ( new Events \ PageTemplateWasChanged ( $ page , $ template ) ) ; return $ page -> getCurrentVersion ( ) -> getStatus ( ) ; } | Set the template of the page . |
227,722 | public function postTitle ( Request $ request , Page $ page ) { $ this -> authorize ( 'edit' , $ page ) ; $ oldTitle = $ page -> getTitle ( ) ; $ page -> setTitle ( $ request -> input ( 'title' ) ) ; Event :: fire ( new Events \ PageTitleWasChanged ( $ page , $ oldTitle , $ page -> getTitle ( ) ) ) ; return [ 'status' ... | Set the title of the page . |
227,723 | public static function merge ( $ file ) { if ( file_exists ( $ file ) ) { $ config = c :: get ( 'boomcms' , [ ] ) ; c :: set ( 'boomcms' , array_merge_recursive ( include $ file , $ config ) ) ; } } | Recursively merges a file into the boomcms config group . |
227,724 | public function creating ( Model $ model ) { if ( $ model instanceof SingleSiteInterface ) { $ site = $ this -> router -> getActiveSite ( ) ? : $ this -> site -> findDefault ( ) ; $ model -> { SingleSiteInterface :: ATTR_SITE } = ( $ site ? $ site -> getId ( ) : null ) ; } } | Set the site_id of the model . |
227,725 | public function init ( ) { $ filename = $ this -> getDirectory ( ) . DIRECTORY_SEPARATOR . $ this -> initFilename ; if ( File :: exists ( $ filename ) ) { File :: requireOnce ( $ filename ) ; } } | Includes the theme s init file if it exists . |
227,726 | public function addAttributesToHtml ( $ html ) { $ html = trim ( ( string ) $ html ) ; $ attributes = array_merge ( $ this -> getRequiredAttributes ( ) , $ this -> attributes ( ) ) ; $ attributesString = Html :: attributes ( $ attributes ) ; return preg_replace ( '|<(.*?)>|' , "<$1$attributesString>" , $ html , 1 ) ; } | This adds the necessary classes to chunk HTML for them to be picked up by the JS editor . i . e . it makes chunks editable . |
227,727 | public function getRequiredAttributes ( ) { return [ $ this -> attributePrefix . 'chunk' => $ this -> getType ( ) , $ this -> attributePrefix . 'slot-name' => $ this -> slotname , $ this -> attributePrefix . 'slot-template' => $ this -> template , $ this -> attributePrefix . 'page' => $ this -> page -> getId ( ) , $ th... | Returns an array of HTML attributes which are required to be make the chunk editable . |
227,728 | public function render ( ) { try { $ html = $ this -> html ( ) ; if ( $ this -> editable === true || Editor :: isHistory ( ) ) { $ html = $ this -> addAttributesToHtml ( $ html ) ; } return empty ( $ html ) ? $ html : $ this -> before . $ html . $ this -> after ; } catch ( \ Exception $ e ) { if ( App :: environment ( ... | Attempts to get the chunk data from the cache otherwise calls _execute to generate the cache . |
227,729 | public function html ( ) { if ( ! $ this -> hasContent ( ) && ! $ this -> isEditable ( ) ) { return '' ; } $ content = $ this -> hasContent ( ) ? $ this -> show ( ) : $ this -> showDefault ( ) ; if ( $ content instanceof View && ! empty ( $ this -> viewParams ) ) { $ content -> with ( $ this -> viewParams ) ; } return ... | Generate the HTML to display the chunk . |
227,730 | public function addWordList ( string $ path , $ name ) : self { $ this -> generator -> addWordList ( $ path , $ name ) ; return $ this ; } | Add a word list to the generator . |
227,731 | public function unread ( $ data ) { $ this -> readBytes -= strlen ( $ data ) ; $ this -> data = $ data . $ this -> data ; } | Push again data in data buffer . It s use when you want to extract a bit from a value a let the rest of the code normally read the data |
227,732 | public function readCodedBinary ( ) { $ c = ord ( $ this -> read ( self :: UNSIGNED_CHAR_LENGTH ) ) ; if ( $ c === self :: NULL_COLUMN ) { return '' ; } if ( $ c < self :: UNSIGNED_CHAR_COLUMN ) { return $ c ; } if ( $ c === self :: UNSIGNED_SHORT_COLUMN ) { return $ this -> readUInt16 ( ) ; } if ( $ c === self :: UNSI... | Read a Length Coded Binary number from the data buffer . Length coded numbers can be anywhere from 1 to 9 bytes depending on the value of the first byte . From PyMYSQL source code |
227,733 | public function readUIntBySize ( $ size ) { if ( $ size === self :: UNSIGNED_CHAR_LENGTH ) { return $ this -> readUInt8 ( ) ; } if ( $ size === self :: UNSIGNED_SHORT_LENGTH ) { return $ this -> readUInt16 ( ) ; } if ( $ size === self :: UNSIGNED_INT24_LENGTH ) { return $ this -> readUInt24 ( ) ; } if ( $ size === self... | Read a little endian integer values based on byte number |
227,734 | public function readIntBeBySize ( $ size ) { if ( $ size === self :: UNSIGNED_CHAR_LENGTH ) { return $ this -> readInt8 ( ) ; } if ( $ size === self :: UNSIGNED_SHORT_LENGTH ) { return $ this -> readInt16Be ( ) ; } if ( $ size === self :: UNSIGNED_INT24_LENGTH ) { return $ this -> readInt24Be ( ) ; } if ( $ size === se... | Read a big endian integer values based on byte number |
227,735 | public function getBinarySlice ( $ binary , $ start , $ size , $ binaryLength ) { $ binary >>= $ binaryLength - ( $ start + $ size ) ; $ mask = ( ( 1 << $ size ) - 1 ) ; return $ binary & $ mask ; } | Read a part of binary data and extract a number |
227,736 | public function makeTableMapDTO ( ) { $ data = [ ] ; $ data [ 'table_id' ] = $ this -> binaryDataReader -> readTableId ( ) ; $ this -> binaryDataReader -> advance ( 2 ) ; $ data [ 'schema_length' ] = $ this -> binaryDataReader -> readUInt8 ( ) ; $ data [ 'schema_name' ] = $ this -> binaryDataReader -> read ( $ data [ '... | This describe the structure of a table . It s send before a change append on a table . A end user of the lib should have no usage of this |
227,737 | protected function getBit ( array $ column ) { $ res = '' ; for ( $ byte = 0 ; $ byte < $ column [ 'bytes' ] ; ++ $ byte ) { $ current_byte = '' ; $ data = $ this -> binaryDataReader -> readUInt8 ( ) ; if ( 0 === $ byte ) { if ( 1 === $ column [ 'bytes' ] ) { $ end = $ column [ 'bits' ] ; } else { $ end = $ column [ 'b... | Read MySQL BIT type |
227,738 | public function getAll ( $ termType ) { $ arr = array ( ) ; foreach ( $ this -> terms as $ term ) { if ( ( string ) $ term -> getTermType ( ) === $ termType ) { array_push ( $ arr , $ term ) ; } } return $ arr ; } | Returns all terms that have the given term type or empty array if none . |
227,739 | public function getFirst ( $ termType ) { foreach ( $ this -> terms as $ term ) { if ( ( string ) $ term -> getTermType ( ) === $ termType ) { return $ term ; } } return null ; } | Returns the first term that has the given term type or null if none . |
227,740 | public function convert ( $ asset , $ basePath ) { $ extension = $ this -> getExtension ( $ asset ) ; if ( $ extension !== 'scss' ) { return $ asset ; } $ cssAsset = $ this -> getCssAsset ( $ asset , 'css' ) ; $ inFile = "$basePath/$asset" ; $ outFile = "$basePath/$cssAsset" ; $ this -> compiler -> setImportPaths ( dir... | Converts a given SCSS asset file into a CSS file . |
227,741 | protected function getCssAsset ( string $ filename , string $ newExtension ) : string { $ extensionlessFilename = pathinfo ( $ filename , PATHINFO_FILENAME ) ; $ filenamePosition = strrpos ( $ filename , $ extensionlessFilename ) ; $ relativePath = substr ( $ filename , 0 , $ filenamePosition ) ; return "$relativePath$... | Get the relative path and filename of the asset |
227,742 | private function hasFormProtection ( string $ name ) : bool { $ key = $ this -> getSessionKey ( $ name ) ; return $ this -> session -> has ( $ key ) ; } | Check if a form has a time protection . |
227,743 | private function getFormTime ( string $ name ) : ? DateTime { $ key = $ this -> getSessionKey ( $ name ) ; if ( $ this -> hasFormProtection ( $ name ) ) { return $ this -> session -> get ( $ key ) ; } return null ; } | Gets the form time for specified form . |
227,744 | public function format ( ) : Format \ Format { if ( null === $ this -> format ) { $ this -> format = Format \ Format :: fromJson ( $ this ) ; } return $ this -> format ; } | Returns the format of the original JSON value . |
227,745 | public function setSerialized ( $ serialized ) { try { parent :: setSerialized ( $ serialized ) ; } catch ( \ Exception $ e ) { Yii :: error ( 'Failed to unserlialize cart: ' . $ e -> getMessage ( ) , __METHOD__ ) ; $ this -> _positions = [ ] ; $ this -> saveToSession ( ) ; } } | Sets cart from serialized string |
227,746 | public function addXmls ( $ importXml = false , $ offersXml = false , $ ordersXml = false ) { $ this -> loadImportXml ( $ importXml ) ; $ this -> loadOffersXml ( $ offersXml ) ; $ this -> loadOrdersXml ( $ ordersXml ) ; } | Add XML files . |
227,747 | private function push ( int $ newState ) { array_push ( $ this -> stateStack , $ this -> state ) ; $ this -> state = $ newState ; if ( $ this -> state !== self :: STATE_ROOT ) { array_push ( $ this -> valueStack , $ this -> value ) ; } $ this -> value = [ ] ; } | Push previous layer to the stack and set new state |
227,748 | private function pop ( $ valueToPrevLevel ) { $ this -> state = array_pop ( $ this -> stateStack ) ; if ( $ this -> state !== self :: STATE_ROOT ) { $ this -> value = array_pop ( $ this -> valueStack ) ; $ this -> value [ ] = $ valueToPrevLevel ; } else { $ this -> decoded = $ valueToPrevLevel ; } } | Pop previous layer from the stack and give it a parsed value |
227,749 | public function antispam ( string $ string , bool $ html = true ) : string { if ( $ html ) { return preg_replace_callback ( self :: MAIL_HTML_PATTERN , [ $ this , 'encryptMail' ] , $ string ) ? : '' ; } return preg_replace_callback ( self :: MAIL_TEXT_PATTERN , [ $ this , 'encryptMailText' ] , $ string ) ? : '' ; } | Replaces E - Mail addresses with an alternative text representation . |
227,750 | public function import ( Category $ category , ImportRecordsDataTable $ importRecordsDataTable ) { return $ importRecordsDataTable -> with ( [ 'resource' => $ category , 'tabs' => 'adminarea.categories.tabs' , 'url' => route ( 'adminarea.categories.stash' ) , 'id' => "adminarea-categories-{$category->getRouteKey()}-imp... | Import categories . |
227,751 | public function destroy ( Category $ category ) { $ category -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.categories.index' ) , 'with' => [ 'warning' => trans ( 'cortex/foundation::messages.resource_deleted' , [ 'resource' => trans ( 'cortex/categories::common.category' ) , 'identifier' => $ category -... | Destroy given category . |
227,752 | public static function dump ( string $ filename , $ data , array $ options = [ ] ) : bool { return file_put_contents ( $ filename , self :: encode ( $ data , $ options ) ) !== false ; } | Dump data to bencoded file |
227,753 | public function image ( $ email , $ alt = null , $ attributes = [ ] , $ rating = null ) { $ dimensions = [ ] ; if ( array_key_exists ( 'width' , $ attributes ) ) { $ dimensions [ ] = $ attributes [ 'width' ] ; } if ( array_key_exists ( 'height' , $ attributes ) ) { $ dimensions [ ] = $ attributes [ 'height' ] ; } if ( ... | Return the code of HTML image for a Gravatar . |
227,754 | public function exists ( $ email ) { $ this -> setDefaultImage ( '404' ) ; $ url = $ this -> buildGravatarURL ( $ email ) ; $ headers = get_headers ( $ url , 1 ) ; return substr ( $ headers [ 0 ] , 9 , 3 ) == '200' ; } | Check if a Gravatar image exists . |
227,755 | protected function formatLine ( $ string , $ indent = 0 ) { return str_repeat ( $ this -> spaces , $ indent ) . $ string . $ this -> linebreak ; } | Formats a line |
227,756 | protected function writeObjectInheritance ( $ object , $ parentName ) { try { $ parent = $ this -> reflector -> getClass ( $ parentName ) ; $ longName = $ parent -> getName ( ) ; $ this -> writeObjectElement ( $ parent ) ; } catch ( \ Exception $ e ) { $ parts = explode ( '\\' , $ parentName ) ; $ shortName = array_pop... | Prints an object inheritance |
227,757 | protected function writeObjectInterfaces ( $ object , $ interfaces ) { foreach ( $ interfaces as $ interfaceName ) { try { $ interface = $ this -> reflector -> getClass ( $ interfaceName ) ; $ longName = $ interface -> getName ( ) ; $ this -> writeObjectElement ( $ interface ) ; } catch ( \ Exception $ e ) { $ parts = ... | Prints interfaces that implement an object |
227,758 | protected function writeConstantElements ( $ constants , $ format = '%s %s\l' , $ indent = - 1 ) { $ constantString = '' ; foreach ( $ constants as $ name => $ value ) { $ line = sprintf ( $ format , '+' , $ name ) ; if ( $ indent >= 0 ) { $ constantString .= $ this -> formatLine ( $ line , $ indent ) ; } else { $ cons... | Prints class constants |
227,759 | protected function writePropertyElements ( $ properties , $ format = '%s %s\l' , $ indent = - 1 ) { $ propertyString = '' ; foreach ( $ properties as $ property ) { if ( $ property -> isPrivate ( ) ) { $ visibility = '-' ; } elseif ( $ property -> isProtected ( ) ) { $ visibility = '#' ; } else { $ visibility = '+' ; }... | Prints class properties |
227,760 | protected function writeMethodElements ( $ methods , $ format = '%s %s()\l' , $ indent = - 1 ) { $ methodString = '' ; foreach ( $ methods as $ method ) { if ( $ method -> isPrivate ( ) ) { $ visibility = '-' ; } elseif ( $ method -> isProtected ( ) ) { $ visibility = '#' ; } else { $ visibility = '+' ; } if ( $ method... | Prints class methods |
227,761 | protected function writeGraphHeader ( ) { $ nodeAttributes = array ( 'fontname' => "Verdana" , 'fontsize' => 8 , 'shape' => "none" , 'margin' => 0 , 'fillcolor' => '#FEFECE' , 'style' => 'filled' , ) ; $ edgeAttributes = array ( 'fontname' => "Verdana" , 'fontsize' => 8 , ) ; $ indent = 1 ; $ graph = $ this -> formatLi... | Prints header of the main graph |
227,762 | protected function generateSamples ( ) : void { $ module = str_after ( $ this -> getNameInput ( ) , '/' ) ; $ this -> call ( 'make:config' , [ 'name' => 'config' , '--module' => $ this -> getNameInput ( ) ] ) ; $ this -> call ( 'make:model' , [ 'name' => 'Example' , '--module' => $ this -> getNameInput ( ) ] ) ; $ this... | Generate code samples . |
227,763 | protected function processStubs ( $ stubs , $ path ) : void { $ this -> makeDirectory ( $ path ) ; $ this -> files -> copyDirectory ( $ stubs , $ path ) ; $ files = [ ( $ phpunit = $ path . DIRECTORY_SEPARATOR . 'phpunit.xml.dist' ) => $ this -> files -> get ( $ phpunit ) , ( $ composer = $ path . DIRECTORY_SEPARATOR .... | Process stubs placeholders . |
227,764 | protected function rootNamespace ( ) : string { return $ this -> rootNamespace ?? $ this -> rootNamespace = implode ( '\\' , array_map ( 'ucfirst' , explode ( '/' , trim ( $ this -> moduleName ( ) ) ) ) ) ; } | Get the root namespace for the class . |
227,765 | protected function moduleName ( ) : string { return $ this -> moduleName ?? $ this -> input -> getOption ( 'module' ) ?? $ this -> moduleName = $ this -> ask ( 'What is your module?' ) ; } | Get the module name for the class . |
227,766 | public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ handler ) : ResponseInterface { $ serviceHandler = $ request -> getAttribute ( RouterMiddleware :: ATTRIBUTE ) ; $ handlerAdapter = App :: getBean ( 'serviceHandlerAdapter' ) ; $ response = $ handlerAdapter -> doHandler ( $ request ,... | execute service with handler |
227,767 | public function findByPK ( $ id , array $ load = [ ] ) { return $ this -> getSelector ( ) -> wherePK ( $ id ) -> load ( $ load ) -> findOne ( ) ; } | Find document by it s primary key . |
227,768 | public function findOne ( array $ query = [ ] , array $ sortBy = [ ] , array $ load = [ ] ) { return $ this -> getSelector ( ) -> orderBy ( $ sortBy ) -> load ( $ load ) -> findOne ( $ query ) ; } | Select one document from mongo collection . |
227,769 | public function getIndexes ( ) : \ Generator { $ definitions = $ this -> reflection -> getProperty ( 'indexes' ) ?? [ ] ; foreach ( $ definitions as $ definition ) { yield $ this -> castIndex ( $ definition ) ; } } | Returns set of declared indexes . |
227,770 | protected function packDefaults ( AbstractTable $ table ) : array { $ mutators = $ this -> buildMutators ( $ table ) ; $ defaults = [ ] ; foreach ( $ table -> getColumns ( ) as $ column ) { $ field = $ column -> getName ( ) ; $ default = $ column -> getDefaultValue ( ) ; if ( ! is_null ( $ default ) && ! is_object ( $ ... | Generate set of default values to be used by record . |
227,771 | protected function mutateValue ( array $ mutators , string $ field , $ default ) { if ( isset ( $ mutators [ RecordEntity :: MUTATOR_SETTER ] [ $ field ] ) ) { try { $ setter = $ mutators [ RecordEntity :: MUTATOR_SETTER ] [ $ field ] ; $ default = call_user_func ( $ setter , $ default ) ; return $ default ; } catch ( ... | Process value thought associated mutator if any . |
227,772 | public function republishCommand ( string $ collection = 'persistent' ) : void { $ collectionName = $ collection ; $ collection = $ this -> resourceManager -> getCollection ( $ collectionName ) ; if ( ! $ collection ) { $ this -> outputLine ( '<error>The collection %s does not exist.</error>' , [ $ collectionName ] ) ;... | Republish a collection |
227,773 | public function actionLogout ( ) { Yii :: $ app -> user -> logout ( ) ; $ back = Yii :: $ app -> request -> post ( 'back' ) ? : Yii :: $ app -> request -> get ( 'back' ) ; return $ back ? $ this -> redirect ( $ back ) : $ this -> goHome ( ) ; } | Logout action . |
227,774 | public function actionContact ( ) { $ model = new ContactForm ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> contact ( Yii :: $ app -> params [ 'adminEmail' ] ) ) { Yii :: $ app -> session -> setFlash ( 'contactFormSubmitted' ) ; return $ this -> refresh ( ) ; } return $ this -> render... | Displays contact page and sends contact form . |
227,775 | public function extractRelations ( array & $ data ) { $ relations = array_intersect_key ( $ data , $ this -> schema ) ; foreach ( $ relations as $ name => $ relation ) { $ this -> relations [ $ name ] = $ relation ; unset ( $ data [ $ name ] ) ; } } | Extract relations data from given entity fields . |
227,776 | public function queueRelations ( ContextualCommandInterface $ parent ) : ContextualCommandInterface { if ( empty ( $ this -> relations ) ) { return $ parent ; } $ transaction = new TransactionalCommand ( ) ; foreach ( $ this -> leadingRelations ( ) as $ relation ) { if ( $ relation -> isLoaded ( ) ) { $ transaction -> ... | Generate command tree with or without relation to parent command in order to specify update or insert sequence . Commands might define dependencies between each other in order to extend FK values . |
227,777 | public function get ( string $ relation ) : RelationInterface { if ( isset ( $ this -> relations [ $ relation ] ) && $ this -> relations [ $ relation ] instanceof RelationInterface ) { return $ this -> relations [ $ relation ] ; } $ instance = $ this -> orm -> makeRelation ( $ this -> class , $ relation ) ; if ( array_... | Get associated relation instance . |
227,778 | public function isJoined ( ) : bool { if ( ! empty ( $ this -> options [ 'using' ] ) ) { return true ; } return in_array ( $ this -> getMethod ( ) , [ self :: INLOAD , self :: JOIN , self :: LEFT_JOIN ] ) ; } | Indicated that loaded must generate JOIN statement . |
227,779 | public function isLoaded ( ) : bool { return $ this -> getMethod ( ) !== self :: JOIN && $ this -> getMethod ( ) !== self :: LEFT_JOIN ; } | Indication that loader want to load data . |
227,780 | protected function configureQuery ( SelectQuery $ query , bool $ loadColumns = true , array $ outerKeys = [ ] ) : SelectQuery { if ( $ loadColumns ) { if ( $ this -> isJoined ( ) ) { $ this -> mountColumns ( $ query , $ this -> options [ 'minify' ] ) ; } else { $ this -> mountColumns ( $ query , $ this -> options [ 'mi... | Configure query with conditions joins and columns . |
227,781 | protected function getAlias ( ) : string { if ( ! empty ( $ this -> options [ 'using' ] ) ) { return $ this -> options [ 'using' ] ; } if ( ! empty ( $ this -> options [ 'alias' ] ) ) { return $ this -> options [ 'alias' ] ; } throw new LoaderException ( "Unable to resolve loader alias" ) ; } | Relation table alias . |
227,782 | protected function localKey ( $ key ) { if ( empty ( $ this -> schema [ $ key ] ) ) { return null ; } return $ this -> getAlias ( ) . '.' . $ this -> schema [ $ key ] ; } | Generate sql identifier using loader alias and value from relation definition . Key name to be fetched from schema . |
227,783 | protected function ensureAlias ( AbstractLoader $ parent ) { if ( empty ( $ this -> options [ 'alias' ] ) ) { if ( $ this -> isLoaded ( ) && $ this -> isJoined ( ) ) { $ this -> options [ 'alias' ] = 'd' . decoct ( ++ self :: $ countLevels ) ; } else { $ this -> options [ 'alias' ] = $ parent -> getAlias ( ) . '_' . $ ... | Ensure table alias . |
227,784 | public function doHandler ( ServerRequestInterface $ request , array $ handler ) : Response { $ data = $ request -> getAttribute ( PackerMiddleware :: ATTRIBUTE_DATA ) ; $ params = $ data [ 'params' ] ?? [ ] ; list ( $ serviceClass , $ method ) = $ handler ; $ service = App :: getBean ( $ serviceClass ) ; $ response = ... | Execute service handler |
227,785 | public function getName ( ) : string { if ( ! empty ( $ this -> name ) ) { return $ this -> name ; } $ name = ( $ this -> isUnique ( ) ? 'unique_' : 'index_' ) . join ( '_' , $ this -> getColumns ( ) ) ; return strlen ( $ name ) > 64 ? md5 ( $ name ) : $ name ; } | Generate unique index name . |
227,786 | protected function mountColumns ( SelectQuery $ query , bool $ minify = false , string $ prefix = '' , bool $ overwrite = false ) { $ alias = $ this -> getAlias ( ) ; $ columns = $ overwrite ? [ ] : $ query -> getColumns ( ) ; foreach ( $ this -> getColumns ( ) as $ name ) { $ column = $ name ; if ( $ minify ) { $ colu... | Set columns into SelectQuery . |
227,787 | public function withContext ( RelationContext $ source , RelationContext $ target = null ) : self { $ definition = clone $ this ; $ definition -> sourceContext = $ source ; $ definition -> targetContext = $ target ; return $ definition ; } | Set relation contexts . |
227,788 | public function locateSchemas ( ) : array { if ( ! $ this -> container -> has ( ClassesInterface :: class ) ) { return [ ] ; } $ classes = $ this -> container -> get ( ClassesInterface :: class ) ; $ schemas = [ ] ; foreach ( $ classes -> getClasses ( RecordEntity :: class ) as $ class ) { if ( $ class [ 'abstract' ] )... | Locate all available document schemas in a project . |
227,789 | public function registerRelation ( SchemaBuilder $ builder , RelationDefinition $ definition ) { if ( ! $ this -> config -> hasRelation ( $ definition -> getType ( ) ) ) { throw new DefinitionException ( sprintf ( "Undefined relation type '%s' in '%s'.'%s'" , $ definition -> getType ( ) , $ definition -> sourceContext ... | Registering new relation definition . At this moment function would not check if relation is unique and will redeclare it . |
227,790 | public function inverseRelations ( SchemaBuilder $ builder ) { foreach ( $ this -> relations as $ relation ) { $ definition = $ relation -> getDefinition ( ) ; if ( $ definition -> needInversion ( ) ) { if ( ! $ relation instanceof InversableRelationInterface ) { throw new DefinitionException ( sprintf ( "Unable to inv... | Create inverse relations where needed . |
227,791 | public function packRelations ( string $ class , SchemaBuilder $ builder ) : array { $ result = [ ] ; foreach ( $ this -> relations as $ relation ) { $ definition = $ relation -> getDefinition ( ) ; if ( $ definition -> sourceContext ( ) -> getClass ( ) == $ class ) { $ result [ $ definition -> getName ( ) ] = $ relati... | Pack relation schemas for specific model class in order to be saved in memory . |
227,792 | protected function locateOuter ( SchemaBuilder $ builder , RelationDefinition $ definition ) : RelationDefinition { if ( ! empty ( $ definition -> targetContext ( ) ) ) { return $ definition ; } $ found = null ; foreach ( $ builder -> getSchemas ( ) as $ schema ) { if ( $ this -> matchBinded ( $ definition -> getTarget... | Populate entity target based on interface or role . |
227,793 | private function matchBinded ( string $ target , SchemaInterface $ schema ) : bool { if ( $ schema -> getRole ( ) == $ target ) { return true ; } if ( interface_exists ( $ target ) && is_a ( $ schema -> getClass ( ) , $ target , true ) ) { return true ; } return false ; } | Check if schema matches relation target . |
227,794 | protected function mapResourceAbilities ( ) : array { $ controller = new ReflectionClass ( static :: class ) ; $ methods = array_filter ( $ controller -> getMethods ( ReflectionMethod :: IS_PUBLIC ) , function ( $ item ) use ( $ controller ) { return $ item -> class === $ controller -> name && mb_substr ( $ item -> nam... | Map resource actions to resource abilities . |
227,795 | public function add ( RecordInterface $ record ) : self { $ this -> assertValid ( $ record ) ; $ this -> loadData ( true ) -> instances [ ] = $ record ; return $ this ; } | Add new record into entity set . Attention usage of this method WILL load relation data unless partial . |
227,796 | public function delete ( RecordInterface $ record ) : self { $ this -> loadData ( true ) ; $ this -> assertValid ( $ record ) ; foreach ( $ this -> instances as $ index => $ instance ) { if ( $ this -> match ( $ instance , $ record ) ) { unset ( $ this -> instances [ $ index ] ) ; $ this -> deleteInstances [ ] = $ inst... | Delete one record strict compaction make sure exactly same instance is given . |
227,797 | public function setExpressions ( array $ expressions ) { $ this -> expressions = array ( ) ; foreach ( $ expressions as $ expression ) { $ this -> addExpression ( $ expression ) ; } return $ this ; } | Set the set of subexpressions |
227,798 | protected function _setDefaultPlaceholderValue ( $ value ) { if ( ! is_null ( $ value ) ) { $ value = $ this -> _normalizeStringable ( $ value ) ; } $ this -> defaultPlaceholderValue = $ value ; } | Assigns a default placeholder value to this instance . |
227,799 | public function validateCode ( ErrorElement $ errorElement , $ object ) { $ code = $ object -> getCode ( ) ; $ registry = $ this -> getConfigurationPool ( ) -> getContainer ( ) -> get ( 'blast_core.code_generators' ) ; $ codeGenerator = $ registry -> getCodeGenerator ( Plot :: class ) ; if ( ! empty ( $ code ) && ! $ c... | Plot code validator . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.