idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
10,600 | private function setCORSheaders ( $ request , $ response , $ next ) { $ settings = new Settings ( ) ; $ settings -> setServerOrigin ( [ 'scheme' => $ request -> getUri ( ) -> getScheme ( ) , 'host' => $ request -> getUri ( ) -> getHost ( ) , 'port' => $ request -> getUri ( ) -> getPort ( ) , ] ) -> setRequestCredential... | Set the CORS headers |
10,601 | public function create ( $ pid , $ attrs = [ ] ) { if ( isset ( $ attrs [ 'constants' ] ) ) { $ attrs [ 'constants' ] = $ this -> parseTsConstants ( $ attrs [ 'constants' ] ) ; } return parent :: create ( $ pid , $ attrs ) ; } | Create a new template record . |
10,602 | private function parseTsConstants ( $ tsConstants ) { if ( is_array ( $ tsConstants ) ) { $ parsed = '' ; foreach ( $ tsConstants as $ constant => $ value ) { $ parsed .= $ constant . ' = ' . $ value . PHP_EOL ; } return $ parsed ; } return $ tsConstants ; } | Parse TS constants into a string . |
10,603 | public function copyAssets ( array $ options ) { $ appname = '#none' ; $ symlink = false ; if ( in_array ( "--symlink" , $ options [ "options" ] ) ) { $ symlink = true ; } if ( $ this -> strlikeInArray ( "--appname" , $ options [ "options" ] ) != null ) { $ ch = $ this -> strlikeInArray ( "--appname" , $ options [ "opt... | Copy asset manager |
10,604 | private function runServer ( ) { if ( $ this -> getCurrentEnv ( ) === "dev" ) { if ( empty ( $ this -> options [ "options" ] ) ) { $ a = new Runner ( ) ; $ a -> run ( ) ; } else { $ host = null ; $ port = null ; $ secure = false ; $ root = null ; $ router = null ; $ cert = null ; $ cluster = 10 ; if ( ( $ a = $ this ->... | Run the development server without options |
10,605 | protected function initializeBundleSelection ( array $ attr ) { try { $ parentProductId = $ this -> mapSku ( $ this -> getValue ( ColumnKeys :: BUNDLE_PARENT_SKU ) ) ; } catch ( \ Exception $ e ) { throw $ this -> wrapException ( array ( ColumnKeys :: BUNDLE_PARENT_SKU ) , $ e ) ; } try { $ productId = $ this -> mapSku... | Initialize the bundle selection with the passed attributes and returns an instance . |
10,606 | protected function obtainTokenFromSession ( ) { global $ _SESSION ; if ( ! isset ( $ _SESSION [ 'formsTokens' ] ) ) { throw new Exception ( 'no token found' , $ this :: ERR_NO_TOKEN ) ; } if ( ! isset ( $ _SESSION [ 'formsTokens' ] [ $ this -> formId ] ) ) { throw new Exception ( 'no token found for the form id ' . $ t... | Get a token from the session |
10,607 | public function createToken ( int $ expire = 15 ) : string { $ token = uniqid ( rand ( ) , true ) ; $ saveInfos = ( object ) [ 'token' => $ token , 'date' => new DateTime , 'expire' => $ expire ] ; $ this -> saveToken ( $ saveInfos ) ; return $ saveInfos -> token ; } | Create a token for the form and return the token |
10,608 | public function checkToken ( string $ tokenToCheck ) : bool { $ tokenInfos = $ this -> obtainToken ( ) ; $ token = $ tokenInfos -> token ; $ dateCreate = $ tokenInfos -> date ; $ timeExpire = $ tokenInfos -> expire ; if ( $ token !== $ tokenToCheck ) { return false ; } $ limitDate = new DateTime ; $ limitDate -> modify... | Check the token receive with the generated token |
10,609 | public function processDatamap_postProcessFieldArray ( $ status , $ table , $ id , & $ fields , $ dh ) { if ( $ table === $ this -> table ) { if ( $ status === 'new' ) { $ res = $ this -> creating ( $ fields ) ; if ( is_array ( $ res ) ) { $ fields = $ res ; } } else { $ res = $ this -> updating ( $ id , $ fields ) ; i... | TYPO3 pre - save hook . |
10,610 | public function processDatamap_afterDatabaseOperations ( $ status , $ table , $ id , $ fields , $ dh ) { if ( $ table === $ this -> table ) { $ uid = $ this -> getUid ( $ status , $ id , $ dh ) ; if ( $ status === 'new' ) { $ this -> created ( $ uid , $ fields ) ; } else { $ this -> updated ( $ uid , $ fields ) ; } $ t... | TYPO3 post - save hook . |
10,611 | public function processCmdmap_deleteAction ( $ table , $ id , $ fields , & $ cancel , $ dh ) { if ( $ table === $ this -> table ) { if ( ( $ res = $ this -> deleting ( $ id , $ fields ) ) !== null ) { $ cancel = ! $ res ; } } } | TYPO3 pre - delete hook . |
10,612 | public function createConnection ( HostConfiguration $ configuration ) { if ( $ this -> cache -> offsetExists ( $ configuration ) ) { return $ this -> cache -> offsetGet ( $ configuration ) ; } $ connection = new SocketConnection ( ) ; $ connection -> setConfiguration ( $ configuration ) ; $ connection -> open ( ) ; $ ... | Create new connection |
10,613 | public function flush ( ) : void { if ( empty ( $ this -> buffers ) ) { return ; } foreach ( $ this -> buffers as $ buffer ) { try { $ this -> sender -> sendTo ( $ buffer [ 0 ] , $ buffer [ 1 ] , $ buffer [ 2 ] ) ; } catch ( SenderException $ e ) { if ( 404 === $ e -> getCode ( ) ) { $ this -> manager -> remove ( $ buf... | Flush all pushes . |
10,614 | public function getLastIndice ( ) { $ last = $ this -> getFirstIndice ( ) - 1 + $ this -> getLimit ( ) ; if ( $ last > $ this -> getTotal ( ) ) { $ last = $ this -> getTotal ( ) ; } return $ last ; } | Returns last indice . |
10,615 | public function getLastPage ( ) { return ( int ) \ max ( self :: MIN_PAGE , \ ceil ( $ this -> getTotal ( ) / $ this -> getLimit ( ) ) ) ; } | Returns last page . |
10,616 | public function getNextPage ( ) { $ nextPage = $ this -> getPage ( ) + 1 ; $ lastPage = $ this -> getLastPage ( ) ; if ( $ lastPage < $ nextPage ) { $ nextPage = $ lastPage ; } return $ nextPage ; } | Returns next page . |
10,617 | public function getPreviousPage ( ) { $ previousPage = $ this -> getPage ( ) - 1 ; $ firstPage = $ this -> getFirstPage ( ) ; if ( $ firstPage > $ previousPage ) { $ previousPage = $ firstPage ; } return $ previousPage ; } | Returns previous page . |
10,618 | public function getLinks ( $ nb = 5 ) { $ links = [ ] ; $ fistPage = $ this -> getFirstPage ( ) ; $ lastPage = $ this -> getLastPage ( ) ; $ currentPage = $ this -> getPage ( ) ; $ firstLink = $ currentPage - $ nb ; $ lastLink = $ currentPage + $ nb ; if ( $ fistPage > $ firstLink ) { $ firstLink = $ fistPage ; } if ( ... | Return pager navigation links . |
10,619 | protected function fixPage ( ) { if ( null !== $ this -> total ) { $ this -> page = \ min ( $ this -> page , $ this -> getLastPage ( ) ) ; } } | Fix current page so it is not past the last one . |
10,620 | public function parse ( $ content ) { $ log = new Log ; $ description = [ ] ; $ links = [ ] ; $ matches = [ ] ; $ bodyEnded = false ; $ line = current ( $ content ) ; while ( $ line !== false ) { $ line = ltrim ( $ line ) ; if ( preg_match ( '/^#(?!#).+/' , $ line ) === 1 ) { $ log -> setTitle ( $ this -> trimHashes ( ... | Takes the given content and parses it into a populated Log object . |
10,621 | public function parseRelease ( & $ content ) { $ release = new Release ; $ types = [ ] ; $ lastType = '' ; $ nameSet = false ; $ line = current ( $ content ) ; while ( $ line !== false ) { $ line = ltrim ( $ line ) ; if ( $ this -> startsWith ( $ line , '###' ) ) { $ type = $ this -> trimHashes ( $ line ) ; $ types [ $... | Builds a release . |
10,622 | protected function handleName ( Release $ release , $ line ) { $ this -> setName ( $ release , $ line ) ; $ this -> setDate ( $ release , $ line ) ; $ this -> setLink ( $ release , $ line ) ; $ this -> setYanked ( $ release , $ line ) ; } | Pulls out the needed information from a Release title and assigns that to the given release . |
10,623 | protected function setLink ( Release $ release , $ line ) { $ matches = [ ] ; if ( preg_match ( '/^## \[([\w\.-\.]+)\](?:\[(\w+)\])?/' , $ line , $ matches ) ) { if ( count ( $ matches ) >= 3 ) { $ release -> setLink ( $ matches [ 2 ] ) ; $ release -> setLinkName ( $ matches [ 2 ] ) ; } else { $ release -> setLink ( $ ... | Extracts and sets the name of the link if there is one . |
10,624 | protected function setDate ( Release $ release , $ line ) { $ matches = [ ] ; if ( preg_match ( '/[0-9]{4,}-[0-9]{2,}-[0-9]{2,}/' , $ line , $ matches ) ) { $ date = DateTime :: createFromFormat ( 'Y-m-d' , $ matches [ 0 ] ) ; if ( $ date ) { $ release -> setDate ( $ date ) ; } } } | Extracts and sets the release Date . |
10,625 | protected function setName ( Release $ release , $ line ) { $ matches = [ ] ; if ( preg_match ( '/([\w\.-]{1,})/' , $ line , $ matches ) ) { $ release -> setName ( $ matches [ 0 ] ) ; } } | Extracts and sets the Release name . |
10,626 | public static function output ( string $ message , string $ interface = 'file' ) { $ env = FEnv :: get ( "framework.env" ) ; $ file_debug = FEnv :: get ( ( "dev" === $ env ) ? "framework.logs.debug.dev.file" : "framework.logs.debug.prod.file" ) ; if ( self :: $ logstatus == true ) { self :: input ( $ message ) ; if ( $... | Display a message |
10,627 | public static function input ( string $ message ) : bool { $ now = new DateTime ( ) ; $ now = $ now -> format ( 'Y-m-d H:i:s' ) ; $ message = trim ( $ message ) ; self :: $ logformat = array ( "time" => $ now , "msg" => $ message ) ; return true ; } | Create template display |
10,628 | private static function log ( $ action , Logable $ model ) { $ modelId = $ model -> getLogName ( ) ; if ( empty ( $ modelId ) ) : throw new \ InvalidArgumentException ( "model_id must be set, it is currently {$model->getLogName()}" ) ; endif ; $ obj = Model \ Action :: where ( 'name' , '=' , $ action ) -> limit ( 1 ) -... | Log a message to the database |
10,629 | private static function compileSassContentWithSassPhp ( string $ content , array $ directories ) { if ( empty ( $ content ) ) { return '' ; } if ( self :: $ sassCompilerInstance == null ) { self :: $ sassCompilerInstance = self :: getSassPhpInstance ( ) ; } self :: updateSassPhpInstance ( self :: $ sassCompilerInstance... | Compile Sass content using SassPhp compiler . |
10,630 | private static function compileSassFileWithSassPhp ( string $ path , array $ directories ) { if ( ! file_exists ( $ path ) ) { return "" ; } if ( ! empty ( $ path ) ) { $ directories [ ] = dirname ( $ path ) ; } if ( self :: $ sassCompilerInstance == null ) { self :: $ sassCompilerInstance = self :: getSassPhpInstance ... | Compile Sass file using SassPhp compiler . |
10,631 | private static function compileSassContentWithLeafoScss ( string $ content , array $ directories ) { if ( empty ( $ content ) ) { return '' ; } if ( self :: $ sassCompilerInstance == null ) { self :: $ sassCompilerInstance = self :: getLeafoScssInstance ( ) ; } self :: updateLeafoScssInstance ( self :: $ sassCompilerIn... | Compile Sass content using Leafo s ScssPhp compiler . |
10,632 | private static function compileSassFileWithLeafoScss ( string $ path , array $ directories ) { if ( ! file_exists ( $ path ) ) { return "" ; } if ( ! empty ( $ path ) ) { $ directories [ ] = dirname ( $ path ) ; } if ( self :: $ sassCompilerInstance == null ) { self :: $ sassCompilerInstance = self :: getLeafoScssInsta... | Compile Sass file using Leafo s ScssPhp compiler . |
10,633 | protected function mergePassedGroup ( $ asset , $ group = null ) { if ( ! $ this -> groupPrefix ) { return $ group ; } $ group = $ group ? $ group : $ this -> namer -> guessGroup ( $ asset ) ; return $ this -> groupName ( $ group ) ; } | Merged the pased group with the namespace . |
10,634 | public function truncate ( ) { $ json = $ this -> getClient ( ) -> delete ( 'data/' . $ this -> getDataSet ( ) -> id ) ; return ( isset ( $ json [ 'success' ] ) && $ json [ 'success' ] ) ; } | Remove all rows from the dataset |
10,635 | public function removeRow ( $ numberOrRow ) { if ( $ numberOrRow instanceof Row ) { $ id = $ numberOrRow -> getRowNumber ( ) ; } elseif ( Row :: isValidNumber ( $ numberOrRow ) ) { $ id = $ numberOrRow ; } else { throw new \ InvalidArgumentException ( 'Invalid row identifier' ) ; } $ putData = array ( 'method' => 'shif... | Remove a row from the dataset |
10,636 | public function removeColumn ( $ number ) { if ( false === Cell :: parseRef ( $ number ) ) { throw new \ InvalidArgumentException ( 'Invalid column identifier' ) ; } $ putData = array ( 'method' => 'shiftCol' , 'index' => $ number - 1 , 'amount' => 1 ) ; $ setId = $ this -> getDataSet ( ) -> id ; $ result = $ this -> g... | Remove a column from the dataset |
10,637 | public function setMimeType ( $ mimeType ) { if ( ! in_array ( $ mimeType , $ this -> knownMimetypes ) ) { throw new UnsupportedParameterException ( "I cannot handle mimetype '$mimeType', only " . implode ( ',' , $ this -> knownMimetypes ) ) ; } $ this -> mimeType = $ mimeType ; return $ this ; } | Set the mimeType of this serializer . |
10,638 | protected function isGDResource ( $ resource ) { if ( ! is_resource ( $ resource ) ) { return false ; } if ( strtolower ( get_resource_type ( $ resource ) != 'gd' ) ) { return false ; } return true ; } | Check if the passed resource is a gd resource . |
10,639 | public function process ( array $ row ) { foreach ( $ this -> processors as $ processor ) { $ row = call_user_func ( $ processor , $ row ) ; } return $ row ; } | Go through all the processors |
10,640 | public function removeProcessor ( callable $ processor ) { $ res = array_search ( $ processor , $ this -> processors , true ) ; if ( $ res !== false ) { unset ( $ this -> processors [ $ res ] ) ; } return $ this ; } | Remove a processor |
10,641 | private function getModuleNavigation ( ) { $ modules = $ this -> getDoctrine ( ) -> getRepository ( Module :: class ) -> findBy ( [ "active" => true , "displayed" => true ] ) ; foreach ( $ modules as $ module ) { $ navigation = json_decode ( file_get_contents ( $ this -> get ( "ribs_admin.globals" ) -> getBaseBundlePat... | to get all modules navigation and test right navigation |
10,642 | public function flashMessage ( $ message , string $ type = 'info' ) : stdClass { parent :: flashMessage ( $ message , $ type ) ; return $ this -> presenter -> flashMessage ( $ message , $ type ) ; } | Saves the message to template . |
10,643 | public function generateSchema ( SchemaDescriptor $ schema ) { $ response = new GeneratorResponse ( ) ; foreach ( $ schema -> getFields ( ) as $ field ) { $ this -> updateFieldOptions ( $ schema , $ field ) ; } if ( $ schema -> isMixinSchema ( ) ) { $ this -> generateMixin ( $ schema , $ response ) ; $ this -> generate... | Generates code for the given SchemaDescriptor . |
10,644 | public function schemaToClassName ( SchemaDescriptor $ schema , $ withMajor = false ) { $ className = StringUtils :: toCamelFromSlug ( $ schema -> getId ( ) -> getMessage ( ) ) ; if ( ! $ withMajor ) { return $ className ; } return "{$className}V{$schema->getId()->getVersion()->getMajor()}" ; } | Returns the class name to be used for the given SchemaDescriptor . |
10,645 | public function schemaToFqClassName ( SchemaDescriptor $ schema , $ withMajor = false ) { $ id = $ schema -> getId ( ) ; $ vendor = StringUtils :: toCamelFromSlug ( $ id -> getVendor ( ) ) ; $ package = StringUtils :: toCamelFromSlug ( str_replace ( '.' , '-' , $ id -> getPackage ( ) ) ) ; return "{$vendor}{$package}{$... | Returns a fully qualified class name to be used for the given SchemaDescriptor . Use this in generated code to avoid name collisions . |
10,646 | public function schemaToNativePackage ( SchemaDescriptor $ schema ) { $ id = $ schema -> getId ( ) ; return $ this -> getNativePackage ( $ id -> getVendor ( ) , $ id -> getPackage ( ) ) ; } | Returns the native package name for the SchemaDescriptor as looked up in compile options or created automatically . |
10,647 | public function enumToNativePackage ( EnumDescriptor $ enum ) { $ id = $ enum -> getId ( ) ; return $ this -> getNativePackage ( $ id -> getVendor ( ) , $ id -> getPackage ( ) ) ; } | Returns the native package name for the EnumDescriptor as looked up in compile options or created automatically . |
10,648 | public function schemaToNativeClassPath ( SchemaDescriptor $ schema ) { $ path = $ this -> schemaToNativeNamespace ( $ schema ) ; $ class = $ this -> schemaToClassName ( $ schema , true ) ; $ delim = 'php' === static :: LANGUAGE ? '\\' : '/' ; return "{$path}{$delim}{$class}" ; } | Returns the native class path for the SchemaDescriptor by combining native namespace and class name with major . |
10,649 | protected function getTwig ( ) { if ( null === $ this -> twig ) { $ this -> twig = new \ Twig_Environment ( new \ Twig_Loader_Filesystem ( self :: TEMPLATE_DIR ) , [ 'debug' => true , 'cache' => false , 'strict_variables' => true , 'autoescape' => false , ] ) ; $ this -> twig -> addExtension ( new StringExtension ( ) )... | Get the twig environment that will render skeletons . |
10,650 | protected function callListeners ( array $ listeners , $ args = [ ] ) { $ called = false ; foreach ( $ listeners as $ listener ) { Helper :: call ( $ listener , is_array ( $ args ) ? $ args : [ $ args ] ) ; $ called = true ; } return $ called ; } | Calls the assigned after listeners . |
10,651 | public function hasResponder ( $ type ) { if ( ! is_string ( $ type ) || empty ( $ type ) ) { throw new \ InvalidArgumentException ( 'The responder type is invalid' ) ; } return isset ( $ this -> responders [ $ type ] ) ; } | Checks if a responder is assigned to the given type . |
10,652 | public function getResponder ( $ type ) { if ( ! is_string ( $ type ) || empty ( $ type ) ) { throw new \ InvalidArgumentException ( 'The responder type is invalid' ) ; } return $ this -> responders [ $ type ] ? : null ; } | Gets the responder of the given type . |
10,653 | public function setResponder ( $ type , ResponderInterface $ responder ) { if ( ! is_string ( $ type ) || empty ( $ type ) ) { throw new \ InvalidArgumentException ( 'The responder type is invalid' ) ; } $ this -> responders [ $ type ] = $ responder ; } | Assigns the responder to the given type . |
10,654 | protected function composeKey ( $ key ) { $ key = ! $ this -> keyPrefix ? $ key : $ this -> keyPrefix . $ key ; return $ key ; } | Build the key if a domain or namespace was set . |
10,655 | public function onAfterInit ( & $ controller ) { if ( $ this -> autoInclude ( ) && $ js = $ this -> getPiwik ( false ) ) { Requirements :: customScript ( $ js , 'piwiktrackingcode' ) ; } } | includes the piwik tracking code when ContentController initializes ... |
10,656 | public function getPiwik ( $ wrap = true ) { if ( Director :: isDev ( ) && ! Config :: inst ( ) -> get ( PiwikExtension :: class , 'show_on_dev' ) ) { return false ; } if ( Director :: isTest ( ) && ! Config :: inst ( ) -> get ( PiwikExtension :: class , 'show_on_test' ) ) { return false ; } if ( Director :: isLive ( )... | generates piwik tracking code out of config vars and Piwik . ss template |
10,657 | public function autoInclude ( ) { if ( ! Config :: inst ( ) -> get ( PiwikExtension :: class , 'auto_include' ) ) { return false ; } if ( Director :: is_cli ( ) ) { return false ; } if ( $ this -> isBlockedController ( ) ) { return false ; } if ( $ this -> isBackend ( ) && ! Config :: inst ( ) -> get ( PiwikExtension :... | Helper function to define if tracking code should be included automatically |
10,658 | protected function fillOnce ( ) { $ payload = $ this -> payload ( ) ; if ( is_array ( $ payload ) ) { return $ this -> fillAttributes ( $ payload ) ; } if ( $ payload instanceof Arrayable ) { return $ this -> fillAttributes ( $ payload -> toArray ( ) ) ; } if ( $ payload instanceof \ Traversable ) { return $ this -> fi... | Fills the array when accessing it . |
10,659 | protected function findStatusInHeaders ( $ headers ) { if ( ! isset ( $ headers [ 0 ] ) || strpos ( $ headers [ 0 ] , 'HTTP/' ) !== 0 ) { throw new UnexpectedValueException ( 'Invalid HTTP Headers, missing status line' ) ; } $ parts = explode ( ' ' , trim ( $ headers [ 0 ] ) ) ; return ( int ) trim ( $ parts [ 1 ] ) ; ... | Tries to find the http status code in its header . |
10,660 | protected function findContentTypeInHeaders ( $ headers ) { foreach ( $ headers as $ header ) { $ lower = trim ( strtolower ( $ header ) ) ; if ( strpos ( $ lower , 'content-type:' ) !== 0 ) { continue ; } $ parts = explode ( ';' , $ header ) ; $ keyAndValue = explode ( ': ' , trim ( $ parts [ 0 ] ) , 2 ) ; if ( ! isse... | Tries to find the content type in the assigned headers . |
10,661 | protected function createPayload ( ) { if ( ! $ this -> body ) { return null ; } if ( ! $ this -> serializer ) { throw new UnConfiguredException ( 'No serializer assigned, cannot build the payload.' ) ; } return $ this -> serializer -> deserialize ( $ this -> body ) ; } | Try to create the payload out of the assigned body . |
10,662 | protected function renderBody ( ) { if ( is_scalar ( $ this -> payload ) || $ this -> payload === null ) { return ( string ) $ this -> payload ; } if ( $ this -> payload instanceof Stringable ) { return $ this -> payload -> toString ( ) ; } if ( is_object ( $ this -> payload ) && method_exists ( $ this -> payload , '__... | Try to create the body out of the assigned payload . |
10,663 | public function applyOrder ( $ order ) { if ( $ order == 'new' ) { $ this -> newest ( ) ; } elseif ( $ order == 'hottest' ) { $ this -> hottest ( ) ; } elseif ( $ order == 'reward' ) { $ this -> reward ( ) ; } elseif ( $ order == 'unanswered' ) { $ this -> unAnswered ( ) ; } } | Apply possible questions order to query |
10,664 | public function getOrFail ( $ id ) { if ( $ model = $ this -> get ( $ id ) ) { return $ model ; } throw ( new NotFoundException ( "No results for id $id" ) ) -> setModel ( get_class ( $ this -> model ) ) ; } | Find a model by its id . Throw a NotFoundException if not found . |
10,665 | public function make ( array $ attributes = [ ] ) { $ model = $ this -> model -> newInstance ( $ attributes ) ; $ this -> publish ( 'made' , $ model ) ; return $ model ; } | Instantiate a new model and fill it with the attributes . |
10,666 | public function store ( array $ attributes ) { $ model = $ this -> make ( [ ] ) ; $ this -> validate ( $ attributes , 'store' ) ; $ this -> fill ( $ model , $ attributes ) ; $ this -> publish ( 'storing' , $ model , $ attributes ) ; $ this -> save ( $ model ) ; $ this -> publish ( 'stored' , $ model , $ attributes ) ; ... | Create a new model by the given attributes and persist it . |
10,667 | public function delete ( Identifiable $ model ) { $ this -> checkIsModel ( $ model ) ; $ this -> publish ( 'deleting' , $ model ) ; $ model -> delete ( ) ; $ this -> publish ( 'deleted' , $ model ) ; } | Delete the passed model . |
10,668 | protected function toModelAttributes ( $ model , $ attributes ) { $ filtered = [ ] ; $ filter = $ this -> getAttributeFilter ( ) ; foreach ( $ attributes as $ key => $ value ) { if ( ! $ filter ( $ key , $ value ) ) { continue ; } $ filtered [ $ key ] = $ value ; } return $ filtered ; } | Cast an clean the incoming attributes so that this repository can savely pass them to the database . The attributes have to be validated before passing them to this method . |
10,669 | public function subscribe ( ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } $ this -> getConnection ( ) -> getClient ( ) -> subscribe ( array ( $ this -> name ) , array ( $ this , "receiveMessage" ) ) ; return $ this ; } | Subscribes to the channel |
10,670 | public function publish ( $ message ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } $ this -> _data [ ] = $ message ; return $ this -> getConnection ( ) -> getClient ( ) -> publish ( $ this -> name , $ message ) ; } | Publishes a message to the channel |
10,671 | public function receiveMessage ( $ redis , $ channel , $ message ) { $ this -> _data [ ] = $ message ; $ event = new Event ( $ this ) ; $ this -> onReceiveMessage ( $ event ) ; } | Receives a message from a subscribed channel |
10,672 | private static function taskbarArrayTemplate ( ) : array { $ options = array ( ) ; try { $ um = new MasterCore ( ) ; $ options [ 'css' ] = FEnv :: get ( "host.web.components.libs.framework" ) . "assets/css/iumioTaskBar.css" ; $ options [ 'css_icon' ] = FEnv :: get ( "host.web.components.libs.framework" ) . "iumio-manag... | This is iumio task bar template options |
10,673 | private function createContent ( ServerRequestInterface $ request ) { $ route = $ request -> getAttribute ( 'route' ) ; $ template = $ this -> viewInflector -> inflect ( $ route ) ; $ this -> templateEngine -> parse ( $ template ) ; return $ this -> templateEngine -> process ( $ request -> getAttribute ( 'viewData' , [... | Generates the content form request attributes |
10,674 | protected function updateOptions ( UriInterface $ uri ) { $ query = $ this -> options [ 'query' ] ; if ( $ this -> options [ 'reuseParams' ] ) { $ query = array_merge ( $ query , $ this -> request -> getQueryParams ( ) ) ; } $ queryString = http_build_query ( $ query ) ; $ uri = $ uri -> withQuery ( $ queryString ) ; r... | Updates the URI according to existing options |
10,675 | private function updateHostName ( UriInterface $ uri ) { if ( ! $ this -> options [ 'reuseHostName' ] ) { return $ uri ; } $ params = $ this -> request -> getServerParams ( ) ; $ hasPort = ! in_array ( $ params [ 'SERVER_PORT' ] , [ '80' , '443' ] ) ; if ( $ hasPort ) { $ uri = $ uri -> withPort ( $ params [ 'SERVER_PO... | Adds the scheme host name and port to the provided URI |
10,676 | private function getParsedData ( ) { if ( is_array ( $ this -> parsedData ) ) { return $ this -> parsedData ; } $ this -> parsedData = [ 'routes' => [ ] ] ; $ content = $ this -> getYmlFileContent ( ) ; try { $ parsedData = $ this -> parser -> parse ( $ content ) ; $ this -> addGeneralDefaults ( $ parsedData ) ; $ this... | Get YML parsed data array |
10,677 | private function getYmlFileContent ( string $ fileName = null ) : string { $ fileName = $ fileName ? : $ this -> routesFile ; if ( ! is_file ( $ fileName ) ) { throw new RoutesFileNotFoundException ( "The routes file '{$fileName}' was not found on your system." ) ; } return file_get_contents ( $ fileName ) ; } | Get contents form YML file |
10,678 | private function setDefaults ( Map $ map ) { foreach ( $ this -> getParsedData ( ) as $ name => $ value ) { if ( in_array ( $ name , $ this -> defaults ) ) { $ map -> $ name ( $ value ) ; } } } | Set map defaults |
10,679 | private function addRoutes ( Map $ map ) { $ data = $ this -> getParsedData ( ) ; $ routes = ( array_key_exists ( 'routes' , $ data ) ) ? $ data [ 'routes' ] : [ ] ; foreach ( $ routes as $ name => $ definition ) { $ this -> routeFactory -> parse ( $ name , $ definition , $ map ) ; } } | Add routes to the provided route map |
10,680 | public static function getSimpleAppFormat ( array $ apps ) : array { $ narray = array ( ) ; foreach ( $ apps as $ oneapp => $ val ) { $ e = AppConfig :: getInstance ( $ oneapp ) ; if ( $ e -> checkVisibility ( ) ) { array_push ( $ narray , array ( "name" => $ oneapp , "value" => $ val ) ) ; } } return ( $ narray ) ; } | Get all simple app |
10,681 | public static function detectDefaultApp ( array $ apps ) : array { foreach ( $ apps as $ oneapp => $ val ) { if ( $ val [ 'isdefault' ] == "yes" ) { return ( array ( "name" => $ oneapp , "value" => $ val ) ) ; } } throw new Server500 ( new \ ArrayObject ( array ( "explain" => "No Default app is detected" , "solution" =... | Detect the default app |
10,682 | final public static function getClassFile ( ) : \ stdClass { $ a = json_decode ( file_get_contents ( FEnv :: get ( "framework.config.core.apps.file" ) ) ) ; return ( $ a == null ? new \ stdClass ( ) : $ a ) ; } | Return app declaration file |
10,683 | final public static function getBaseClassFile ( ) : \ stdClass { $ a = json_decode ( file_get_contents ( FEnv :: get ( "framework.baseapps.apps.file" ) ) ) ; return ( $ a == null ? new \ stdClass ( ) : $ a ) ; } | Return base app declaration file |
10,684 | public function getEntryById ( string $ sectionHandle , string $ id ) : JsonResponse { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; $ optionsResponse = $ this -> preFlightOptions ( $ request , self :: ALLOWED_HTTP_METHODS ) ; if ( $ optionsResponse ) { return $ optionsResponse ; } $ this -> dispatcher ... | GET an entry by id |
10,685 | public function createEntry ( string $ sectionHandle ) : JsonResponse { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; $ optionsResponse = $ this -> preFlightOptions ( $ request , self :: ALLOWED_HTTP_METHODS ) ; if ( $ optionsResponse ) { return $ optionsResponse ; } $ this -> dispatcher -> dispatch ( A... | POST a new entry |
10,686 | public function deleteEntryById ( string $ sectionHandle , int $ id ) : JsonResponse { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; $ optionsResponse = $ this -> preFlightOptions ( $ request , self :: ALLOWED_HTTP_METHODS ) ; if ( $ optionsResponse ) { return $ optionsResponse ; } $ this -> dispatcher ... | DELETE an entry by it s id |
10,687 | public function deleteEntryBySlug ( string $ sectionHandle , string $ slug ) : JsonResponse { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; $ optionsResponse = $ this -> preFlightOptions ( $ request , self :: ALLOWED_HTTP_METHODS ) ; if ( $ optionsResponse ) { return $ optionsResponse ; } $ this -> disp... | DELETE an entry by it s slug |
10,688 | protected function putToPost ( ) : void { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; $ put = $ request -> getContent ( ) ; parse_str ( $ put , $ _POST ) ; $ _SERVER [ 'REQUEST_METHOD' ] = 'POST' ; } | Symfony doesn t know how to handle put . Transform put data to POST . |
10,689 | protected function errorResponse ( Request $ request , \ Exception $ exception ) : JsonResponse { if ( $ exception instanceof EntryNotFoundException || $ exception instanceof SectionNotFoundException ) { $ statusCode = JsonResponse :: HTTP_NOT_FOUND ; } else { $ statusCode = JsonResponse :: HTTP_BAD_REQUEST ; } return ... | Build a JSON response to return when an exception occurs . |
10,690 | protected function getFields ( ) : ? array { $ fields = $ this -> requestStack -> getCurrentRequest ( ) -> get ( 'fields' ) ; if ( ! is_null ( $ fields ) ) { $ fields = array_map ( 'trim' , explode ( ',' , $ fields ) ) ; } return $ fields ; } | You can restrict the fields you desire to see |
10,691 | public static function parse ( $ raw ) { if ( $ raw == 'stop' ) { return self :: STOPPED ; } elseif ( $ raw == 'pause' ) { return self :: PAUSED ; } elseif ( $ raw == 'play' ) { return self :: PLAYING ; } return 3 ; } | Parse state from raw response |
10,692 | public function get ( $ key , $ default = null ) { if ( isset ( $ this -> queryHits [ $ key ] ) ) { return $ this -> queryHits [ $ key ] ; } if ( isset ( $ this -> queryMisses [ $ key ] ) ) { return $ default ; } list ( $ namespace , $ dataKey ) = $ this -> namespaceAndKey ( $ key ) ; $ prefix = $ this -> firstKeySegme... | Get a named object by its id . |
10,693 | public function getOrFail ( $ key ) { $ value = $ this -> get ( $ key , new None ( ) ) ; if ( ! $ value instanceof None ) { return $ value ; } throw new KeyNotFoundException ( "Key '$key' not found'" ) ; } | Get a named object by its id or throw an exception if it cant be found . |
10,694 | protected function dataForPrefix ( $ namespace , $ prefix ) { if ( ! isset ( $ this -> cachedData [ $ namespace ] [ $ prefix ] ) ) { $ this -> loadDataForPrefix ( $ namespace , $ prefix ) ; } if ( ! isset ( $ this -> customData [ $ namespace ] [ $ prefix ] ) ) { return $ this -> cachedData [ $ namespace ] [ $ prefix ] ... | Return the data from an added array . |
10,695 | protected function loadDataForPrefix ( $ namespace , $ prefix ) { $ this -> failOnMissingNamespace ( $ namespace ) ; if ( ! isset ( $ this -> cachedData [ $ namespace ] ) ) { $ this -> cachedData [ $ namespace ] = [ ] ; } if ( ! isset ( $ this -> cachedData [ $ namespace ] [ $ prefix ] ) ) { $ this -> cachedData [ $ na... | Load the data from an added array |
10,696 | protected function prefixLength ( $ namespace , $ key ) { if ( isset ( $ this -> prefixLengths [ $ namespace ] ) ) { return $ this -> prefixLengths [ $ namespace ] ; } $ firstSegment = $ this -> firstKeySegments ( $ key ) ; $ this -> failOnMissingNamespace ( $ namespace ) ; foreach ( $ this -> addedData [ $ namespace ]... | Determine the amount of segments that should be cached . Within a normal array this is always 1 . But some storages are using nested directories and these needs a minimum key segments . This is done once and perhaps expensive depends on the storage . |
10,697 | protected function namespaceAndKey ( $ key ) { if ( $ this -> hasNamespace ( $ key ) ) { return explode ( $ this -> nsSeparator , $ key , 2 ) ; } return [ 'default' , $ key ] ; } | Return the namespace and key separately . |
10,698 | protected function arrayKey ( $ key , $ prefix ) { $ arrayKey = substr ( $ key , strlen ( $ prefix ) + 1 ) ; return is_bool ( $ arrayKey ) ? '' : $ arrayKey ; } | Return the array key inside a cached array . |
10,699 | private function mergeAutoload ( RootPackageInterface $ root ) { if ( ! empty ( $ autoload = $ this -> getPackage ( ) -> getAutoload ( ) ) ) { static :: unwrapIfNeeded ( $ root , 'setAutoload' ) -> setAutoload ( array_merge_recursive ( $ root -> getAutoload ( ) , Util :: fixRelativePaths ( $ this -> getPath ( ) , $ aut... | Merge autoload into a RootPackage . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.