idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
45,700
public static function create ( array $ options ) { $ formatterClass = ucfirst ( ! empty ( $ options [ 'driverOptions' ] [ 'format' ] ) ? $ options [ 'driverOptions' ] [ 'format' ] : 'json' ) ; $ className = preg_match ( '/\\\\/' , $ formatterClass ) ? $ formatterClass : 'Circle\DoctrineRestDriver\Formatters\\' . $ formatterClass ; Assertions :: assertClassExists ( $ className ) ; return self :: assert ( new $ className ( $ options ) ) ; }
Returns the right format
45,701
public static function create ( array $ tokens , $ content ) { if ( empty ( $ content ) || ! is_array ( $ content ) ) return [ ] ; return empty ( $ content [ 0 ] ) ? SelectSingleResult :: create ( $ tokens , $ content ) : SelectAllResult :: create ( $ tokens , $ content ) ; }
Returns a valid Doctrine result for SELECT ...
45,702
public static function columns ( array $ tokens ) { $ columns = array_filter ( $ tokens [ 'INSERT' ] , function ( $ token ) { return $ token [ 'expr_type' ] === 'column-list' ; } ) ; return array_map ( function ( $ column ) { return end ( $ column [ 'no_quotes' ] [ 'parts' ] ) ; } , end ( $ columns ) [ 'sub_tree' ] ) ; }
returns the columns as list
45,703
public static function values ( array $ tokens ) { $ values = explode ( ',' , self :: removeBrackets ( self :: removeSpacesBetweenComma ( end ( $ tokens [ 'VALUES' ] ) [ 'base_expr' ] ) ) ) ; return array_map ( function ( $ value ) { return Value :: create ( $ value ) ; } , $ values ) ; }
returns the values as list
45,704
public static function get ( RoutingTable $ annotations , $ entityAlias , $ method ) { if ( ! self :: exists ( $ annotations , $ entityAlias , $ method ) ) return null ; return $ annotations -> get ( $ entityAlias ) -> $ method ( ) ; }
returns the corresponding data source annotation if exists
45,705
public static function exists ( RoutingTable $ annotations = null , $ entityAlias , $ method ) { return ! empty ( $ annotations ) && $ annotations -> get ( $ entityAlias ) !== null && $ annotations -> get ( $ entityAlias ) -> $ method ( ) !== null ; }
checks if the annotation exists
45,706
public static function assert ( $ value , $ varName ) { return ! is_int ( $ value ) && $ value !== null ? Exceptions :: InvalidTypeException ( 'MaybeInt' , $ varName , $ value ) : $ value ; }
Asserts if the given value is a maybe int
45,707
public function setCurlOptions ( array $ options ) { return new Request ( [ 'method' => $ this -> method , 'url' => $ this -> url , 'curlOptions' => $ options , 'query' => $ this -> query , 'payload' => $ this -> payload , 'expectedStatusCodes' => $ this -> expectedStatusCodes ] ) ; }
sets the curl options
45,708
public static function create ( array $ options ) { HashMap :: assert ( $ options , 'options' ) ; $ filteredKeys = array_filter ( array_keys ( $ options ) , function ( $ key ) { return strpos ( $ key , 'CURLOPT_' ) === 0 ; } ) ; $ filteredOptions = array_intersect_key ( $ options , array_flip ( $ filteredKeys ) ) ; $ keys = array_map ( function ( $ key ) { return constant ( $ key ) ; } , array_keys ( $ filteredOptions ) ) ; $ optionsWithIntKeys = array_combine ( $ keys , array_values ( $ filteredOptions ) ) ; return $ optionsWithIntKeys + self :: $ defaults ; }
Returns an array containing CURLOPT options that can be added to the PHP internal curl library by using curl_setopt_array
45,709
public static function setParams ( $ query , array $ params = [ ] ) { Str :: assert ( $ query , 'query' ) ; return array_reduce ( $ params , function ( $ query , $ param ) { $ param = self :: getStringRepresentation ( $ param ) ; return strpos ( $ query , '?' ) ? substr_replace ( $ query , $ param , strpos ( $ query , '?' ) , strlen ( '?' ) ) : $ query ; } , $ query ) ; }
replaces param placeholders with corresponding params
45,710
public static function quoteUrl ( $ query ) { $ queryParts = explode ( ' ' , Str :: assert ( $ query , 'query' ) ) ; return trim ( array_reduce ( $ queryParts , function ( $ carry , $ part ) { return $ carry . ( Url :: is ( $ part ) ? ( '"' . $ part . '" ' ) : ( $ part . ' ' ) ) ; } ) ) ; }
quotes the table if it s an url
45,711
public static function create ( array $ tokens ) { HashMap :: assert ( $ tokens , 'tokens' ) ; if ( empty ( $ tokens [ 'WHERE' ] ) ) return '' ; $ idAlias = self :: alias ( $ tokens ) ; return array_reduce ( $ tokens [ 'WHERE' ] , function ( $ carry , $ token ) use ( $ tokens , $ idAlias ) { if ( $ carry !== null ) return ( string ) Value :: create ( $ carry ) ; if ( $ token [ 'expr_type' ] === 'colref' && $ token [ 'base_expr' ] === $ idAlias ) return $ tokens [ 'WHERE' ] [ $ carry + 2 ] [ 'base_expr' ] ; if ( ! isset ( $ tokens [ $ carry + 1 ] ) ) return '' ; } , null ) ; }
Returns the id in the WHERE clause if exists
45,712
public static function alias ( array $ tokens ) { $ column = self :: column ( $ tokens , new MetaData ( ) ) ; $ tableAlias = Table :: alias ( $ tokens ) ; return empty ( $ tableAlias ) ? $ column : $ tableAlias . '.' . $ column ; }
Returns the id alias
45,713
public static function column ( array $ tokens , MetaData $ metaData ) { $ table = Table :: create ( $ tokens ) ; $ meta = array_filter ( $ metaData -> get ( ) , function ( $ meta ) use ( $ table ) { return $ meta -> getTableName ( ) === $ table ; } ) ; $ idColumns = ! empty ( $ meta ) ? end ( $ meta ) -> getIdentifierColumnNames ( ) : [ ] ; return ! empty ( $ idColumns ) ? end ( $ idColumns ) : 'id' ; }
returns the column of the id
45,714
public static function create ( $ route , $ apiUrl , $ id = null ) { Str :: assert ( $ route , 'route' ) ; Str :: assert ( $ apiUrl , 'apiUrl' ) ; MaybeString :: assert ( $ id , 'id' ) ; $ idPath = empty ( $ id ) ? '' : '/' . $ id ; if ( ! self :: is ( $ route ) ) return $ apiUrl . '/' . $ route . $ idPath ; if ( ! preg_match ( '/\{id\}/' , $ route ) ) return $ route . $ idPath ; if ( ! empty ( $ id ) ) return str_replace ( '{id}' , $ id , $ route ) ; return str_replace ( '/{id}' , '' , $ route ) ; }
returns an url depending on the given route apiUrl and id
45,715
public static function createFromTokens ( array $ tokens , $ apiUrl , DataSource $ annotation = null ) { $ id = Identifier :: create ( $ tokens ) ; $ route = empty ( $ annotation ) || $ annotation -> getRoute ( ) === null ? Table :: create ( $ tokens ) : $ annotation -> getRoute ( ) ; return self :: create ( $ route , $ apiUrl , $ id ) ; }
returns an url depending on the given tokens
45,716
public static function assert ( $ value , $ varName ) { return ! self :: is ( $ value ) ? Exceptions :: InvalidTypeException ( 'Url' , $ varName , $ value ) : $ value ; }
Asserts if the given value is an url
45,717
public function prepare ( $ statement ) { $ this -> connect ( ) ; $ this -> statement = new Statement ( $ statement , $ this -> getParams ( ) , $ this -> routings ) ; $ this -> statement -> setFetchMode ( $ this -> defaultFetchMode ) ; return $ this -> statement ; }
prepares the statement execution
45,718
public static function ofSqlOperation ( $ operation , $ patchInsert = false ) { if ( $ operation === SqlOperations :: INSERT ) return HttpMethods :: POST ; if ( $ operation === SqlOperations :: SELECT ) return HttpMethods :: GET ; if ( $ operation === SqlOperations :: UPDATE ) return $ patchInsert ? HttpMethods :: PATCH : HttpMethods :: PUT ; if ( $ operation === SqlOperations :: DELETE ) return HttpMethods :: DELETE ; return Exceptions :: InvalidSqlOperationException ( $ operation ) ; }
returns the sql operators equal http method
45,719
public static function create ( $ value ) { Str :: assert ( $ value , 'value' ) ; if ( $ value === 'true' ) return true ; if ( $ value === 'false' ) return false ; if ( $ value === 'null' ) return null ; $ unquoted = preg_replace ( '/^(?|\"(.*)\"|\\\'(.*)\\\'|\`(.*)\`)$/' , '$1' , $ value ) ; if ( ! is_numeric ( $ unquoted ) ) return $ unquoted ; if ( ( string ) intval ( $ unquoted ) === $ unquoted ) return intval ( $ unquoted ) ; return floatval ( $ unquoted ) ; }
Infers the type of a given string
45,720
public static function create ( array $ tokens ) { HashMap :: assert ( $ tokens , 'tokens' ) ; if ( empty ( $ tokens [ 'FROM' ] ) && empty ( $ tokens [ 'INSERT' ] ) && empty ( $ tokens [ 'UPDATE' ] ) ) return Exceptions :: InvalidTypeException ( 'array' , 'tokens' , null ) ; $ operation = SqlOperation :: create ( $ tokens ) ; if ( $ operation === SqlOperations :: INSERT ) return $ tokens [ 'INSERT' ] [ 1 ] [ 'no_quotes' ] [ 'parts' ] [ 0 ] ; if ( $ operation === SqlOperations :: UPDATE ) return $ tokens [ 'UPDATE' ] [ 0 ] [ 'no_quotes' ] [ 'parts' ] [ 0 ] ; return $ tokens [ 'FROM' ] [ 0 ] [ 'no_quotes' ] [ 'parts' ] [ 0 ] ; }
Returns the table name
45,721
public static function alias ( array $ tokens ) { HashMap :: assert ( $ tokens , 'tokens' ) ; $ operation = SqlOperation :: create ( $ tokens ) ; if ( $ operation === SqlOperations :: INSERT ) return null ; if ( $ operation === SqlOperations :: UPDATE ) return $ tokens [ 'UPDATE' ] [ 0 ] [ 'alias' ] [ 'name' ] ; return $ tokens [ 'FROM' ] [ 0 ] [ 'alias' ] [ 'name' ] ; }
Returns the table s alias
45,722
public static function replace ( array $ tokens , $ newTable ) { HashMap :: assert ( $ tokens , 'tokens' ) ; $ operation = SqlOperation :: create ( $ tokens ) ; $ firstKey = $ operation === SqlOperations :: DELETE || $ operation === SqlOperations :: SELECT ? 'FROM' : strtoupper ( $ operation ) ; $ tokens [ $ firstKey ] [ $ operation === SqlOperations :: INSERT ? 1 : 0 ] [ 'no_quotes' ] [ 'parts' ] [ 0 ] = $ newTable ; return $ tokens ; }
replaces the table in the tokens array with the given table
45,723
public function createOne ( $ method , array $ tokens , array $ options , DataSource $ annotation = null ) { return new Request ( [ 'method' => HttpMethod :: create ( $ method , $ annotation ) , 'url' => Url :: createFromTokens ( $ tokens , $ options [ 'host' ] , $ annotation ) , 'curlOptions' => CurlOptions :: create ( array_merge ( $ options [ 'driverOptions' ] , HttpHeader :: create ( $ options [ 'driverOptions' ] , $ tokens ) ) ) , 'query' => HttpQuery :: create ( $ tokens , $ options [ 'driverOptions' ] ) , 'payload' => Payload :: create ( $ tokens , $ options ) , 'expectedStatusCodes' => StatusCode :: create ( $ method , $ annotation ) ] ) ; }
Creates a new Request with the given options
45,724
public static function InvalidTypeException ( $ expectedType , $ key , $ value ) { throw new InvalidTypeException ( $ expectedType , $ key , is_array ( $ value ) ? serialize ( $ value ) : $ value ) ; }
throws an invalid type exception
45,725
public static function assert ( $ value , $ varName ) { NotNil :: assert ( $ value , $ varName ) ; return ! is_string ( $ value ) ? Exceptions :: InvalidTypeException ( 'string' , $ varName , $ value ) : $ value ; }
Asserts if the given value is a string
45,726
public static function assert ( $ value , $ varName ) { return ! is_string ( $ value ) && $ value !== null ? Exceptions :: InvalidTypeException ( 'MaybeString' , $ varName , $ value ) : $ value ; }
Asserts if the given value is a maybe string
45,727
public static function create ( array $ options , array $ tokens ) { $ headers = empty ( $ options [ 'CURLOPT_HTTPHEADER' ] ) ? [ ] : $ options [ 'CURLOPT_HTTPHEADER' ] ; $ headers = empty ( $ headers ) ? [ ] : $ headers ; $ headers = is_string ( $ headers ) ? explode ( ',' , $ headers ) : $ headers ; $ headers = array_merge ( $ headers , ! isset ( $ options [ 'pagination_as_query' ] ) || ! $ options [ 'pagination_as_query' ] ? PaginationHeaders :: create ( $ tokens ) : [ ] , OrderingHeaders :: create ( $ tokens ) ) ; return [ 'CURLOPT_HTTPHEADER' => $ headers ] ; }
Returns an array containing CURLOPT_HTTPHEADER options that can be added to the PHP internal curl library by using curl_setopt_array
45,728
public static function create ( $ method , DataSource $ annotation = null ) { Str :: assert ( $ method , 'method' ) ; $ annotationStatusCodes = ! empty ( $ annotation ) && $ annotation -> getStatusCodes ( ) !== null ? $ annotation -> getStatusCodes ( ) : array ( ) ; return $ annotationStatusCodes ? : self :: $ expectedStatusCodes [ $ method ] ; }
returns the status code depending on its input
45,729
public function send ( Request $ request ) { $ method = strtolower ( $ request -> getMethod ( ) ) ; $ response = $ method === HttpMethods :: GET || $ method === HttpMethods :: DELETE ? $ this -> restClient -> $ method ( $ request -> getUrlAndQuery ( ) , $ request -> getCurlOptions ( ) ) : $ this -> restClient -> $ method ( $ request -> getUrlAndQuery ( ) , $ request -> getPayload ( ) , $ request -> getCurlOptions ( ) ) ; try { return $ request -> isExpectedStatusCode ( $ response -> getStatusCode ( ) ) ? $ response : Exceptions :: RequestFailedException ( $ request , $ response -> getStatusCode ( ) , $ response -> getContent ( ) ) ; } catch ( DBALException \ DriverException $ e ) { $ responseExceptionFactory = new ResponseExceptionFactory ( ) ; throw $ responseExceptionFactory -> createDbalException ( $ response , $ e ) ; } }
sends the request
45,730
private function createId ( array $ tokens ) { $ idColumn = Identifier :: column ( $ tokens , new MetaData ( ) ) ; return empty ( $ this -> result [ $ idColumn ] ) ? null : $ this -> result [ $ idColumn ] ; }
returns the id
45,731
private function createResult ( array $ tokens , $ requestMethod , $ responseCode , array $ content = null ) { if ( $ responseCode >= 400 && $ responseCode < 600 ) return [ ] ; if ( $ requestMethod === HttpMethods :: DELETE ) return [ ] ; $ result = $ requestMethod === HttpMethods :: GET ? SelectResult :: create ( $ tokens , $ content ) : $ content ; krsort ( $ result ) ; return $ result ; }
returns the result
45,732
public function createDbalException ( Response $ response , DriverExceptionInterface $ exception ) { switch ( $ response -> getStatusCode ( ) ) { case Response :: HTTP_BAD_REQUEST : return new DBALException \ SyntaxErrorException ( $ response -> getContent ( ) , $ exception ) ; case Response :: HTTP_METHOD_NOT_ALLOWED : case Response :: HTTP_NOT_ACCEPTABLE : case Response :: HTTP_REQUEST_TIMEOUT : case Response :: HTTP_LENGTH_REQUIRED : case Response :: HTTP_INTERNAL_SERVER_ERROR : return new DBALException \ ServerException ( $ response -> getContent ( ) , $ exception ) ; case Response :: HTTP_CONFLICT : return new DBALException \ ConstraintViolationException ( $ response -> getContent ( ) , $ exception ) ; case Response :: HTTP_UNAUTHORIZED : case Response :: HTTP_FORBIDDEN : case Response :: HTTP_PROXY_AUTHENTICATION_REQUIRED : case Response :: HTTP_BAD_GATEWAY : case Response :: HTTP_SERVICE_UNAVAILABLE : case Response :: HTTP_GATEWAY_TIMEOUT : return new DBALException \ ConnectionException ( $ response -> getContent ( ) , $ exception ) ; default : return new DBALException \ DriverException ( $ response -> getContent ( ) , $ exception ) ; } }
Handle a failed response by creating a specific exception for the given response .
45,733
public static function assert ( $ value , $ varName ) { return ! is_array ( $ value ) && $ value !== null ? Exceptions :: InvalidTypeException ( 'MaybeList' , $ varName , $ value ) : $ value ; }
Asserts if the given value is a maybe list
45,734
public function transform ( $ query ) { $ usePatch = isset ( $ this -> options [ 'driverOptions' ] [ 'use_patch' ] ) ? $ this -> options [ 'driverOptions' ] [ 'use_patch' ] : false ; $ tokens = $ this -> parser -> parse ( $ query ) ; $ method = HttpMethods :: ofSqlOperation ( SqlOperation :: create ( $ tokens ) , $ usePatch ) ; $ annotation = Annotation :: get ( $ this -> routings , Table :: create ( $ tokens ) , $ method ) ; return $ this -> requestFactory -> createOne ( $ method , $ tokens , $ this -> options , $ annotation ) ; }
Transforms the given query into a request object
45,735
public static function create ( array $ tokens , array $ options = [ ] ) { HashMap :: assert ( $ tokens , 'tokens' ) ; $ operation = SqlOperation :: create ( $ tokens ) ; if ( $ operation !== SqlOperations :: SELECT ) return null ; $ query = implode ( '&' , array_filter ( [ self :: createConditionals ( $ tokens ) , self :: createPagination ( $ tokens , $ options ) , ] ) ) ; return $ query ; }
Creates a http query string by using the WHERE clause of the parsed sql tokens
45,736
public static function createConditionals ( array $ tokens ) { if ( ! isset ( $ tokens [ 'WHERE' ] ) ) return '' ; $ tableAlias = Table :: alias ( $ tokens ) ; $ primaryKeyColumn = sprintf ( '%s.%s' , $ tableAlias , Identifier :: column ( $ tokens , new MetaData ) ) ; $ sqlWhereString = array_reduce ( $ tokens [ 'WHERE' ] , function ( $ query , $ token ) use ( $ tableAlias ) { return $ query . str_replace ( [ '"' , '\'' ] , '' , str_replace ( 'OR' , '|' , str_replace ( 'AND' , '&' , $ token [ 'base_expr' ] ) ) ) ; } ) ; return str_replace ( $ tableAlias . '.' , '' , preg_replace ( '/' . preg_quote ( $ primaryKeyColumn ) . '=[\w\d]*&*/' , '' , $ sqlWhereString ) ) ; }
Create a string of conditional parameters .
45,737
public static function createPagination ( array $ tokens , array $ options ) { if ( ! isset ( $ options [ 'pagination_as_query' ] ) || ! $ options [ 'pagination_as_query' ] ) return '' ; $ perPageParam = isset ( $ options [ 'per_page_param' ] ) ? $ options [ 'per_page_param' ] : PaginationQuery :: DEFAULT_PER_PAGE_PARAM ; $ pageParam = isset ( $ options [ 'page_param' ] ) ? $ options [ 'page_param' ] : PaginationQuery :: DEFAULT_PAGE_PARAM ; $ paginationParameters = PaginationQuery :: create ( $ tokens , $ perPageParam , $ pageParam ) ; return $ paginationParameters ? http_build_query ( $ paginationParameters ) : '' ; }
Create a string of pagination parameters
45,738
public function getEntityNamespaces ( ) { return array_reduce ( $ this -> get ( ) , function ( $ carry , $ item ) { $ carry [ $ item -> table [ 'name' ] ] = $ item -> getName ( ) ; return $ carry ; } , [ ] ) ; }
returns all namespaces of managed entities
45,739
public static function orderBy ( array $ tokens , array $ content ) { if ( empty ( $ tokens [ 'ORDER' ] ) ) return $ content ; $ sortingRules = array_map ( function ( $ token ) use ( $ content ) { return [ end ( $ token [ 'no_quotes' ] [ 'parts' ] ) , $ token [ 'direction' ] ] ; } , $ tokens [ 'ORDER' ] ) ; $ reducedSortingRules = array_reduce ( $ sortingRules , 'array_merge' , [ ] ) ; $ sortArgs = array_map ( function ( $ value ) use ( $ content ) { if ( $ value === 'ASC' ) return SORT_ASC ; if ( $ value === 'DESC' ) return SORT_DESC ; $ contents = [ ] ; foreach ( $ content as $ c ) array_push ( $ contents , $ c [ $ value ] ) ; return $ contents ; } , $ reducedSortingRules ) ; $ sortArgs [ ] = & $ content ; call_user_func_array ( 'array_multisort' , $ sortArgs ) ; return end ( $ sortArgs ) ; }
Orders the content with the given order by criteria
45,740
public static function assert ( $ value , $ varName ) { if ( ! is_array ( $ value ) ) return Exceptions :: InvalidTypeException ( 'HashMap' , $ varName , $ value ) ; foreach ( $ value as $ key => $ v ) HashMapEntry :: assert ( [ $ key => $ v ] , $ varName ) ; return $ value ; }
Asserts if the given value is a hash map
45,741
public static function assert ( $ value , $ varName ) { if ( ! is_array ( $ value ) ) return Exceptions :: InvalidTypeException ( 'HashMapEntry' , $ varName , $ value ) ; if ( count ( $ value ) > 1 ) return Exceptions :: InvalidTypeException ( 'HashMapEntry' , $ varName , $ value ) ; $ keys = array_keys ( $ value ) ; $ key = end ( $ keys ) ; Str :: assert ( $ key , 'HashMapEntry of "' . $ varName . '": "' . $ key . '"' ) ; return $ value ; }
Asserts if the given value is a hash map entry
45,742
public static function assertExists ( $ hashMap , $ entryName , $ varName ) { HashMap :: assert ( $ hashMap , $ varName ) ; return array_key_exists ( $ entryName , $ hashMap ) ? $ hashMap : Exceptions :: InvalidTypeException ( 'HashMapEntry' , $ varName . '[\'' . $ entryName . '\']' , 'undefined' ) ; }
Asserts if the given hash map entry exists
45,743
public function start ( ) { if ( $ this -> isRunning ( ) ) { return ; } $ script = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'server' . DIRECTORY_SEPARATOR . 'server.php' ; $ stdout = tempnam ( sys_get_temp_dir ( ) , 'mockserv-stdout-' ) ; $ cmd = "php -S {$this->host}:{$this->port} " . escapeshellarg ( $ script ) ; if ( ! putenv ( self :: TMP_ENV . '=' . $ this -> tmpDir ) ) { throw new Exceptions \ RuntimeException ( 'Unable to put environmental variable' ) ; } $ fullCmd = sprintf ( '%s > %s 2>&1 & echo $!' , escapeshellcmd ( $ cmd ) , escapeshellarg ( $ stdout ) ) ; InternalServer :: incrementRequestCounter ( $ this -> tmpDir , 0 ) ; $ this -> pid = exec ( $ fullCmd , $ o , $ ret ) ; if ( ! ctype_digit ( $ this -> pid ) ) { throw new Exceptions \ ServerException ( "Error starting server, received '{$this->pid}', expected int PID" ) ; } sleep ( 1 ) ; if ( ! $ this -> isRunning ( ) ) { throw new Exceptions \ ServerException ( "Failed to start server. Is something already running on port {$this->port}?" ) ; } $ this -> started = true ; register_shutdown_function ( function ( ) { if ( $ this -> isRunning ( ) ) { $ this -> stop ( ) ; } } ) ; }
Start the Web Server on the selected port and host
45,744
public function isRunning ( ) { if ( ! $ this -> pid ) { return false ; } $ result = shell_exec ( sprintf ( 'ps %d' , $ this -> pid ) ) ; if ( count ( preg_split ( "/\n/" , $ result ) ) > 2 ) { return true ; } return false ; }
Is the Web Server currently running?
45,745
public function stop ( ) { if ( $ this -> started ) { exec ( sprintf ( 'kill %d' , $ this -> pid ) ) ; } $ this -> started = false ; }
Stop the Web Server
45,746
public function getUrlOfResponse ( ResponseInterface $ response ) { $ ref = InternalServer :: storeResponse ( $ this -> tmpDir , $ response ) ; return $ this -> getServerRoot ( ) . '/' . self :: VND . '/' . $ ref ; }
Get a URL providing the specified response .
45,747
public function setResponseOfPath ( $ path , ResponseInterface $ response ) { $ ref = InternalServer :: storeResponse ( $ this -> tmpDir , $ response ) ; $ aliasPath = InternalServer :: aliasPath ( $ this -> tmpDir , $ path ) ; if ( ! file_put_contents ( $ aliasPath , $ ref ) ) { throw new \ RuntimeException ( 'Failed to store path alias' ) ; } return $ this -> getServerRoot ( ) . $ path ; }
Set a specified path to provide a specific response
45,748
public function getLastRequest ( ) { $ path = $ this -> tmpDir . DIRECTORY_SEPARATOR . self :: LAST_REQUEST_FILE ; if ( file_exists ( $ path ) ) { $ content = file_get_contents ( $ path ) ; $ data = @ unserialize ( $ content ) ; if ( $ data instanceof RequestInfo ) { return $ data ; } } return null ; }
Get the previous requests associated request data .
45,749
public function getRequestByOffset ( $ offset ) { $ reqs = glob ( $ this -> tmpDir . DIRECTORY_SEPARATOR . 'request.*' ) ; natsort ( $ reqs ) ; $ item = array_slice ( $ reqs , $ offset , 1 ) ; if ( ! $ item ) { return null ; } $ path = reset ( $ item ) ; $ content = file_get_contents ( $ path ) ; $ data = @ unserialize ( $ content ) ; if ( $ data instanceof RequestInfo ) { return $ data ; } return null ; }
Get request by offset
45,750
private function findOpenPort ( ) { $ sock = socket_create ( AF_INET , SOCK_STREAM , 0 ) ; if ( ! socket_bind ( $ sock , $ this -> getHost ( ) , 0 ) ) { throw new Exceptions \ RuntimeException ( 'Could not bind to address' ) ; } socket_getsockname ( $ sock , $ checkAddress , $ checkPort ) ; socket_close ( $ sock ) ; if ( $ checkPort > 0 ) { return $ checkPort ; } throw new Exceptions \ RuntimeException ( 'Failed to find open port' ) ; }
Let the OS find an open port for you .
45,751
public function refreshApplication ( $ app = null ) { $ this -> app = $ app instanceof Application ? $ app : $ this -> createApplication ( ) ; }
Refresh the application instance .
45,752
protected function createApplication ( ) { putenv ( 'APP_ENV=' . $ this -> getEnv ( ) ) ; $ app = require $ this -> appPath ; $ app -> make ( Kernel :: class ) -> bootstrap ( ) ; Carbon :: setTestNow ( Carbon :: now ( ) ) ; return $ app ; }
Creates a Laravel application .
45,753
public function beforeSpecification ( SpecificationEvent $ event ) { if ( $ event -> getSpecification ( ) -> getClassReflection ( ) -> hasMethod ( 'setLaravel' ) ) { $ this -> laravel -> refreshApplication ( ) ; } }
Run the beforeSpecification hook .
45,754
private function getBootstrapPath ( $ path = null ) { if ( ! $ path ) { $ path = dirname ( $ this -> getVendorPath ( ) ) . '/bootstrap/app.php' ; } elseif ( ! $ this -> isAbsolutePath ( $ path ) ) { $ path = $ this -> getVendorPath ( ) . '/' . $ path ; } if ( ! is_file ( $ path ) ) { throw new InvalidArgumentException ( "App bootstrap at `{$path}` not found." ) ; } return $ path ; }
Get path to bootstrap file .
45,755
public function getTimeout ( ) { if ( $ this -> timeout ) return $ this -> timeout ; $ timeout = 0 ; foreach ( $ this -> requests as $ r ) { $ timeout += $ r -> getTimeout ( ) ; } return $ timeout ; }
Get request timeout
45,756
public function send ( Requests \ Request $ request ) { if ( $ request instanceof Requests \ Batch && count ( $ request -> requests ) > Client :: BATCH_MAX_SIZE ) return $ this -> sendMultipartBatch ( $ request ) ; $ this -> request = $ request ; $ path = Util :: sliceDbName ( $ request -> getPath ( ) ) ; $ request_url = $ path . $ this -> paramsToUrl ( $ request -> getQueryParameters ( ) ) ; $ signed_url = $ this -> signUrl ( $ request_url ) ; $ protocol = ( $ request -> getEnsureHttps ( ) ) ? 'https' : $ this -> protocol ; $ uri = $ protocol . '://' . $ this -> base_uri . $ signed_url ; $ timeout = $ request -> getTimeout ( ) / 1000 ; $ result = null ; try { switch ( $ request -> getMethod ( ) ) { case Requests \ Request :: HTTP_GET : $ result = $ this -> get ( $ uri , $ timeout ) ; break ; case Requests \ Request :: HTTP_PUT : $ json = json_encode ( $ request -> getBodyParameters ( ) , JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ) ; $ result = $ this -> put ( $ uri , $ timeout , $ json ) ; break ; case Requests \ Request :: HTTP_DELETE : $ result = $ this -> delete ( $ uri , $ timeout ) ; break ; case Requests \ Request :: HTTP_POST : $ json = json_encode ( $ request -> getBodyParameters ( ) , JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ) ; $ result = $ this -> post ( $ uri , $ timeout , $ json ) ; break ; } } catch ( \ Requests_Exception $ e ) { if ( strpos ( $ e -> getMessage ( ) , 'cURL error 28' ) !== false ) throw new ApiTimeoutException ( $ request ) ; if ( strpos ( $ e -> getMessage ( ) , 'timed out' ) !== false ) throw new ApiTimeoutException ( $ request ) ; throw $ e ; } return $ result ; }
Send a request to the Recombee API
45,757
public function getTemplateIdentifier ( ) { $ options = $ this -> options ; $ contentView = $ this -> contentView ; $ twig = $ this -> twig ; $ layout = $ this -> configResolver -> getParameter ( 'view_default_layout' , 'ezpublish_legacy' ) ; return static function ( array $ params ) use ( $ options , $ contentView , $ twig , $ layout ) { $ contentViewClosure = $ contentView -> getTemplateIdentifier ( ) ; if ( isset ( $ params [ 'noLayout' ] ) && $ params [ 'noLayout' ] ) { $ layout = $ options [ 'viewbaseLayout' ] ; } $ twigContentTemplate = <<<EOT{% extends "{$layout}" %}{% block {$options['contentBlockName']} %}{{ viewResult|raw }}{% endblock %}EOT ; return $ twig -> render ( $ twigContentTemplate , $ params + [ 'viewResult' => $ contentViewClosure ( $ params ) , ] ) ; } ; }
Returns the registered template identifier .
45,758
public function enterLegacyRootDir ( ) { $ this -> previousRunningDir = getcwd ( ) ; if ( $ this -> logger ) { $ this -> logger -> debug ( "Legacy kernel: Leaving '$this->previousRunningDir' for '$this->legacyRootDir'" ) ; } chdir ( $ this -> legacyRootDir ) ; }
Changes the current working directory to the legacy root dir . Calling this method is mandatory to use legacy kernel since a lot of resources in eZ Publish 4 . x relatively defined .
45,759
public function leaveLegacyRootDir ( ) { $ previousDir = $ this -> previousRunningDir ; if ( ! $ previousDir ) { if ( $ this -> logger ) { $ this -> logger -> warning ( "Trying to leave legacy root dir without a previously executing dir. Falling back to '$this->webRootDir'" ) ; } $ previousDir = $ this -> webRootDir ; } $ this -> previousRunningDir = null ; if ( $ this -> logger ) { $ this -> logger -> debug ( "Legacy kernel: Leaving '$this->legacyRootDir' for '$previousDir'" ) ; } chdir ( $ previousDir ) ; }
Leaves the legacy root dir and switches back to the dir where execution was happening before we entered LegacyRootDir .
45,760
public function onInteractiveLogin ( InteractiveLoginEvent $ e ) { $ request = $ e -> getRequest ( ) ; if ( ! $ e -> getAuthenticationToken ( ) -> isAuthenticated ( ) && $ request -> cookies -> has ( 'is_logged_in' ) ) { $ request -> getSession ( ) -> invalidate ( ) ; $ this -> needsCookieCleanup = true ; } }
Removes current userId stored in session if needed .
45,761
public function onFilterResponse ( FilterResponseEvent $ e ) { if ( $ e -> getRequestType ( ) !== HttpKernelInterface :: MASTER_REQUEST ) { return ; } if ( $ this -> needsCookieCleanup ) { $ e -> getResponse ( ) -> headers -> clearCookie ( 'is_logged_in' ) ; $ this -> needsCookieCleanup = false ; } }
Removes is_logged_in cookie if needed .
45,762
public static function getLegacyTemplatesList ( \ Closure $ legacyKernel ) { $ templateList = [ 'compact' => [ ] , 'full' => [ ] ] ; if ( ! LegacyKernel :: hasInstance ( ) ) { return $ templateList ; } try { $ templateStats = $ legacyKernel ( ) -> runCallback ( static function ( ) { if ( eZTemplate :: isTemplatesUsageStatisticsEnabled ( ) ) { return eZTemplate :: templatesUsageStatistics ( ) ; } else { $ stats = [ ] ; foreach ( eZTemplate :: instance ( ) -> templateFetchList ( ) as $ tpl ) { $ stats [ ] = [ 'requested-template-name' => $ tpl , 'actual-template-name' => $ tpl , 'template-filename' => $ tpl , ] ; } return $ stats ; } } , false , false ) ; } catch ( RuntimeException $ e ) { $ templateStats = [ ] ; } foreach ( $ templateStats as $ tplInfo ) { $ requestedTpl = $ tplInfo [ 'requested-template-name' ] ; $ actualTpl = $ tplInfo [ 'actual-template-name' ] ; $ fullPath = $ tplInfo [ 'template-filename' ] ; $ templateList [ 'full' ] [ $ actualTpl ] = [ 'loaded' => $ requestedTpl , 'fullPath' => $ fullPath , ] ; if ( ! isset ( $ templateList [ 'compact' ] [ $ actualTpl ] ) ) { $ templateList [ 'compact' ] [ $ actualTpl ] = 1 ; } else { ++ $ templateList [ 'compact' ] [ $ actualTpl ] ; } } return $ templateList ; }
Returns array of loaded legacy templates .
45,763
public function contentTypeGroup ( $ id ) { if ( $ this -> allCleared === true || $ this -> isSwitchedOff ( ) ) { return ; } if ( is_scalar ( $ id ) ) { $ this -> cache -> invalidateTags ( [ 'type-group-' . $ id , 'type-map' ] ) ; } else { throw new InvalidArgumentType ( '$id' , 'int|null' , $ id ) ; } }
Clear contentTypeGroup persistence cache by id .
45,764
public function languages ( $ ids ) { if ( $ this -> allCleared === true || $ this -> isSwitchedOff ( ) ) { return ; } $ ids = ( array ) $ ids ; $ tags = [ ] ; foreach ( $ ids as $ id ) { $ tags [ ] = 'language-' . $ id ; } $ this -> cache -> invalidateTags ( $ tags ) ; }
Clear language persistence cache by id .
45,765
public function stateAssign ( $ contentId ) { if ( $ this -> allCleared === true || $ this -> isSwitchedOff ( ) ) { return ; } $ this -> cache -> invalidateTags ( [ 'content-' . $ contentId ] ) ; }
Clear object state assignment persistence cache by content id .
45,766
public function user ( $ id = null ) { if ( $ this -> allCleared === true || $ this -> isSwitchedOff ( ) ) { return ; } if ( $ id === null ) { } elseif ( is_scalar ( $ id ) ) { $ this -> cache -> invalidateTags ( [ 'user-' . $ id ] ) ; } else { throw new InvalidArgumentType ( '$id' , 'int|null' , $ id ) ; } }
Clear meta info on users in Persistence .
45,767
protected function getDoctrineSettings ( array $ databaseSettings ) { $ databaseMapping = [ 'ezmysqli' => 'pdo_mysql' , 'eZMySQLiDB' => 'pdo_mysql' , 'ezmysql' => 'pdo_mysql' , 'eZMySQLDB' => 'pdo_mysql' , 'ezpostgresql' => 'pdo_pgsql' , 'eZPostgreSQL' => 'pdo_pgsql' , 'postgresql' => 'pdo_pgsql' , 'pgsql' => 'pdo_pgsql' , 'oracle' => 'oci8' , 'ezoracle' => 'oci8' , ] ; $ databaseType = $ databaseSettings [ 'DatabaseImplementation' ] ; if ( isset ( $ databaseMapping [ $ databaseType ] ) ) { $ databaseType = $ databaseMapping [ $ databaseType ] ; } $ databasePassword = $ databaseSettings [ 'Password' ] != '' ? $ databaseSettings [ 'Password' ] : null ; $ doctrineSettings = [ 'driver' => $ databaseType , 'host' => $ databaseSettings [ 'Server' ] , 'user' => $ databaseSettings [ 'User' ] , 'password' => $ databasePassword , 'dbname' => $ databaseSettings [ 'Database' ] , 'charset' => 'UTF8' , ] ; if ( isset ( $ databaseSettings [ 'Port' ] ) && ! empty ( $ databaseSettings [ 'Port' ] ) ) { $ doctrineSettings [ 'port' ] = $ databaseSettings [ 'Port' ] ; } if ( isset ( $ databaseSettings [ 'Socket' ] ) && $ databaseSettings [ 'Socket' ] !== 'disabled' ) { $ doctrineSettings [ 'unix_socket' ] = $ databaseSettings [ 'Socket' ] ; } return $ doctrineSettings ; }
Returns settings for Doctrine in respect to database settings coming from legacy .
45,768
protected function getLanguages ( array $ siteList , $ groupName ) { $ result = [ ] ; $ allSame = true ; $ previousSA = null ; foreach ( $ siteList as $ siteaccess ) { $ result [ $ siteaccess ] = $ this -> getParameter ( 'RegionalSettings' , 'SiteLanguageList' , 'site.ini' , $ siteaccess ) ; if ( $ allSame && $ previousSA !== null ) { $ allSame = ( $ result [ $ previousSA ] === $ result [ $ siteaccess ] ) ; } $ previousSA = $ siteaccess ; } if ( $ allSame ) { return [ $ groupName => $ result [ $ previousSA ] ] ; } return $ result ; }
Returns the languages list for all siteaccess unless it s the same for each one in this case it returns the languages list for the group .
45,769
protected function getImageVariations ( array $ siteList , $ groupName ) { $ result = [ ] ; $ allSame = true ; $ previousSA = null ; foreach ( $ siteList as $ siteaccess ) { $ result [ $ siteaccess ] = $ this -> getImageVariationsForSiteaccess ( $ siteaccess ) ; if ( $ allSame && $ previousSA !== null ) { $ allSame = ( $ result [ $ previousSA ] === $ result [ $ siteaccess ] ) ; } $ previousSA = $ siteaccess ; } if ( $ allSame ) { return [ $ groupName => $ result [ $ previousSA ] ] ; } return $ result ; }
Returns the image variations settings for all siteaccess unless it s the same for each one in this case it returns the variations settings for the group . This avoids to duplicate the image variations settings .
45,770
protected function getImageVariationsForSiteaccess ( $ siteaccess ) { $ variations = [ ] ; $ imageAliasesList = $ this -> getGroup ( 'AliasSettings' , 'image.ini' , $ siteaccess ) ; foreach ( $ imageAliasesList [ 'AliasList' ] as $ imageAliasIdentifier ) { $ variationSettings = [ 'reference' => null , 'filters' => [ ] ] ; $ aliasSettings = $ this -> getGroup ( $ imageAliasIdentifier , 'image.ini' , $ siteaccess ) ; if ( isset ( $ aliasSettings [ 'Reference' ] ) && $ aliasSettings [ 'Reference' ] != '' ) { $ variationSettings [ 'reference' ] = $ aliasSettings [ 'Reference' ] ; } if ( isset ( $ aliasSettings [ 'Filters' ] ) && \ is_array ( $ aliasSettings [ 'Filters' ] ) ) { foreach ( $ aliasSettings [ 'Filters' ] as $ filterString ) { $ filteringSettings = [ ] ; if ( strstr ( $ filterString , '=' ) !== false ) { list ( $ filteringSettings [ 'name' ] , $ filterParams ) = explode ( '=' , $ filterString ) ; $ filterParams = explode ( ';' , $ filterParams ) ; array_walk ( $ filterParams , static function ( & $ value ) { if ( preg_match ( '/^[0-9]+$/' , $ value ) ) { $ value = ( int ) $ value ; } } ) ; $ filteringSettings [ 'params' ] = $ filterParams ; } else { $ filteringSettings [ 'name' ] = $ filterString ; } $ variationSettings [ 'filters' ] [ ] = $ filteringSettings ; } } $ variations [ $ imageAliasIdentifier ] = $ variationSettings ; } return $ variations ; }
Returns the image variation settings for the siteaccess .
45,771
public function websiteToolbarAction ( $ locationId = null , $ originalSemanticPathInfo = '' , Request $ request ) { $ response = $ this -> buildResponse ( ) ; if ( isset ( $ this -> csrfTokenManager ) ) { $ parameters [ 'form_token' ] = $ this -> csrfTokenManager -> getToken ( 'legacy' ) -> getValue ( ) ; } if ( $ this -> previewHelper -> isPreviewActive ( ) ) { $ template = 'design:parts/website_toolbar_versionview.tpl' ; $ previewedContent = $ authValueObject = $ this -> previewHelper -> getPreviewedContent ( ) ; $ previewedVersionInfo = $ previewedContent -> versionInfo ; $ parameters = [ 'object' => $ previewedContent , 'version' => $ previewedVersionInfo , 'language' => $ previewedVersionInfo -> initialLanguageCode , 'is_creator' => $ previewedVersionInfo -> creatorId === $ this -> getRepository ( ) -> getCurrentUser ( ) -> id , ] ; } elseif ( $ locationId === null ) { return $ response ; } else { $ authValueObject = $ this -> loadContentByLocationId ( $ locationId ) ; $ template = 'design:parts/website_toolbar.tpl' ; $ parameters = [ 'current_node_id' => $ locationId , 'redirect_uri' => $ originalSemanticPathInfo ? $ originalSemanticPathInfo : $ request -> attributes -> get ( 'semanticPathinfo' ) , ] ; } $ authorizationAttribute = new AuthorizationAttribute ( 'websitetoolbar' , 'use' , [ 'valueObject' => $ authValueObject ] ) ; if ( ! $ this -> authChecker -> isGranted ( $ authorizationAttribute ) ) { return $ response ; } $ response -> setContent ( $ this -> legacyTemplateEngine -> render ( $ template , $ parameters ) ) ; return $ response ; }
Renders the legacy website toolbar template .
45,772
protected function runLegacyKernelCallback ( $ callback ) { $ this -> persistenceCacheClearer -> switchOff ( ) ; $ this -> httpCacheClearer -> switchOff ( ) ; if ( $ this -> legacyKernel instanceof Closure ) { $ legacyKernelClosure = $ this -> legacyKernel ; $ this -> legacyKernel = $ legacyKernelClosure ( ) ; } $ return = $ this -> legacyKernel -> runCallback ( $ callback , false , false ) ; $ this -> persistenceCacheClearer -> switchOn ( ) ; $ this -> httpCacheClearer -> switchOn ( ) ; return $ return ; }
Executes a legacy kernel callback .
45,773
public function loadDataFromModuleResult ( array $ moduleResult ) { $ kernelClosure = $ this -> legacyKernelClosure ; $ that = $ this ; $ kernelClosure ( ) -> runCallback ( static function ( ) use ( $ moduleResult , $ that ) { foreach ( $ moduleResult as $ key => $ val ) { if ( $ key === 'content' ) { continue ; } $ that -> set ( $ key , $ val ) ; } if ( ! isset ( $ moduleResult [ 'content_info' ] [ 'persistent_variable' ] ) ) { $ moduleResult [ 'content_info' ] [ 'persistent_variable' ] = ezjscPackerTemplateFunctions :: getPersistentVariable ( ) ; } $ that -> set ( 'persistent_variable' , $ moduleResult [ 'content_info' ] [ 'persistent_variable' ] ) ; if ( isset ( $ moduleResult [ 'content_info' ] [ 'persistent_variable' ] [ 'css_files' ] ) ) { $ that -> set ( 'css_files' , array_unique ( ezjscPacker :: buildStylesheetFiles ( $ moduleResult [ 'content_info' ] [ 'persistent_variable' ] [ 'css_files' ] , 0 ) ) ) ; } if ( isset ( $ moduleResult [ 'content_info' ] [ 'persistent_variable' ] [ 'js_files' ] ) ) { $ that -> set ( 'js_files' , array_unique ( ezjscPacker :: buildJavascriptFiles ( $ moduleResult [ 'content_info' ] [ 'persistent_variable' ] [ 'js_files' ] , 0 ) ) ) ; } $ designINI = eZINI :: instance ( 'design.ini' ) ; $ that -> set ( 'css_files_configured' , array_unique ( ezjscPacker :: buildStylesheetFiles ( $ designINI -> variable ( 'StylesheetSettings' , 'FrontendCSSFileList' ) , 0 ) ) ) ; $ that -> set ( 'js_files_configured' , array_unique ( ezjscPacker :: buildJavascriptFiles ( $ designINI -> variable ( 'JavaScriptSettings' , 'FrontendJavaScriptList' ) , 0 ) ) ) ; } , false , false ) ; }
Fills up the LegacyHelper with data from a given moduleResult .
45,774
public function renderLegacyJs ( ) { $ jsFiles = [ ] ; $ jsCodeLines = [ ] ; foreach ( $ this -> legacyHelper -> get ( 'js_files' , [ ] ) as $ jsItem ) { if ( ! empty ( $ jsItem ) ) { if ( isset ( $ jsItem [ 4 ] ) && $ this -> isFile ( $ jsItem , '.js' ) ) { $ jsFiles [ ] = $ jsItem ; } else { $ jsCodeLines [ ] = $ jsItem ; } } } return $ this -> environment -> render ( $ this -> jsTemplate , [ 'js_files' => $ jsFiles , 'js_code_lines' => $ jsCodeLines , ] ) ; }
Generates style tags to be embedded in the page .
45,775
public function renderLegacyCss ( ) { $ cssFiles = [ ] ; $ cssCodeLines = [ ] ; foreach ( $ this -> legacyHelper -> get ( 'css_files' , [ ] ) as $ cssItem ) { if ( ! empty ( $ cssItem ) ) { if ( isset ( $ cssItem [ 5 ] ) && $ this -> isFile ( $ cssItem , '.css' ) ) { $ cssFiles [ ] = $ cssItem ; } else { $ cssCodeLines [ ] = $ cssItem ; } } } return $ this -> environment -> render ( $ this -> cssTemplate , [ 'css_files' => $ cssFiles , 'css_code_lines' => $ cssCodeLines , ] ) ; }
Generates script tags to be embedded in the page .
45,776
public function exists ( $ name ) { return $ this -> getLegacyKernel ( ) -> runCallback ( static function ( ) use ( $ name ) { $ legacyTemplate = eZTemplate :: factory ( ) -> loadURIRoot ( $ name , false , $ extraParameters ) ; return ! empty ( $ legacyTemplate ) ; } ) ; }
Returns true if the template exists .
45,777
protected function legalizeLinkParameters ( array $ linkParameters ) { $ parameters = [ ] ; if ( isset ( $ linkParameters [ 'href' ] ) ) { $ parameters [ 'href' ] = $ linkParameters [ 'href' ] ; } if ( isset ( $ linkParameters [ 'resourceFragmentIdentifier' ] ) ) { $ parameters [ 'anchor_name' ] = $ linkParameters [ 'resourceFragmentIdentifier' ] ; } if ( isset ( $ linkParameters [ 'class' ] ) ) { $ parameters [ 'class' ] = $ linkParameters [ 'class' ] ; } if ( isset ( $ linkParameters [ 'id' ] ) ) { $ parameters [ 'xhtml:id' ] = $ linkParameters [ 'id' ] ; } if ( isset ( $ linkParameters [ 'target' ] ) ) { $ parameters [ 'target' ] = $ linkParameters [ 'target' ] ; } if ( isset ( $ linkParameters [ 'title' ] ) ) { $ parameters [ 'xhtml:title' ] = $ linkParameters [ 'title' ] ; } if ( $ linkParameters [ 'resourceType' ] !== null ) { switch ( $ linkParameters [ 'resourceType' ] ) { case EmbedToHtml5 :: LINK_RESOURCE_CONTENT : $ parameters [ 'object_id' ] = $ linkParameters [ 'resourceId' ] ; break ; case EmbedToHtml5 :: LINK_RESOURCE_LOCATION : $ parameters [ 'node_id' ] = $ linkParameters [ 'resourceId' ] ; break ; case EmbedToHtml5 :: LINK_RESOURCE_URL : $ parameters [ 'url_id' ] = $ linkParameters [ 'resourceId' ] ; break ; default : } } return $ parameters ; }
Converts link parameters to Legacy Stack format .
45,778
public function viewMenu ( $ nodeId , $ modified , $ expiry , $ perm ) { $ response = new Response ( ) ; if ( $ this -> getParameter ( 'treemenu.http_cache' ) ) { $ response -> setMaxAge ( $ this -> getParameter ( 'treemenu.ttl_cache' ) ) ; } $ result = $ this -> treeMenuKernel -> run ( ) ; if ( $ result -> hasAttribute ( 'lastModified' ) ) { $ response -> setLastModified ( $ result -> getAttribute ( 'lastModified' ) ) ; } $ response -> setContent ( $ result -> getContent ( ) ) ; return $ response ; }
Action rendering the tree menu for admin interface . Note that parameters are not used at all since the request is entirely forwarded to the legacy kernel .
45,779
public function run ( ) { if ( ! isset ( $ this -> embeddedScriptPath ) ) { throw new RuntimeException ( 'No legacy script to run has been passed. Cannot run, aborting.' ) ; } if ( ! file_exists ( $ this -> embeddedScriptPath ) ) { throw new RuntimeException ( 'Passed legacy script does not exist. Please provide the correct script path, relative to the legacy root.' ) ; } $ this -> sessionInit ( ) ; $ argv = $ _SERVER [ 'argv' ] ; ob_start ( static function ( $ buffer ) { static $ startFlag = false ; if ( ! $ startFlag ) { $ buffer = preg_replace ( '/^\#\![\w\/]*[ ]?php[\r?\n?]/' , '' , $ buffer ) ; $ startFlag = true ; } return $ buffer ; } , 128 ) ; ob_implicit_flush ( true ) ; include $ this -> embeddedScriptPath ; }
Runs a legacy script .
45,780
public function indexAction ( Request $ request ) { $ kernelClosure = $ this -> kernelClosure ; $ kernel = $ kernelClosure ( ) ; $ legacyMode = $ this -> configResolver -> getParameter ( 'legacy_mode' ) ; $ kernel -> setUseExceptions ( false ) ; $ this -> uriHelper -> updateLegacyURI ( $ request ) ; if ( isset ( $ this -> legacyLayout ) && ! $ legacyMode ) { $ kernel -> setUsePagelayout ( false ) ; } $ result = $ kernel -> run ( ) ; $ kernel -> setUseExceptions ( true ) ; if ( $ result instanceof ezpKernelRedirect ) { return $ this -> legacyResponseManager -> generateRedirectResponse ( $ result ) ; } $ this -> legacyHelper -> loadDataFromModuleResult ( $ result -> getAttribute ( 'module_result' ) ) ; $ response = $ this -> legacyResponseManager -> generateResponseFromModuleResult ( $ result ) ; $ this -> legacyResponseManager -> mapHeaders ( headers_list ( ) , $ response ) ; return $ response ; }
Base fallback action . Will be basically used for every legacy module .
45,781
protected function clearCache ( ) { $ oldCacheDirName = "{$this->cacheDir}_old" ; $ this -> fs -> rename ( $ this -> cacheDir , $ oldCacheDirName ) ; $ this -> fs -> remove ( $ oldCacheDirName ) ; }
Clears the configuration cache .
45,782
public function onKernelBuilt ( PostBuildKernelEvent $ event ) { if ( $ this -> enabled === false || ! $ event -> getKernelHandler ( ) instanceof ezpWebBasedKernelHandler || $ this -> configResolver -> getParameter ( 'legacy_mode' ) === true || ! $ this -> isUserAuthenticated ( ) ) { return ; } $ currentUser = $ this -> repository -> getCurrentUser ( ) ; $ event -> getLegacyKernel ( ) -> runCallback ( static function ( ) use ( $ currentUser ) { $ legacyUser = eZUser :: fetch ( $ currentUser -> id ) ; eZUser :: setCurrentlyLoggedInUser ( $ legacyUser , $ legacyUser -> attribute ( 'contentobject_id' ) , eZUser :: NO_SESSION_REGENERATE ) ; } , false , false ) ; }
Performs actions related to security once the legacy kernel has been built .
45,783
protected function getPreAuthenticatedData ( Request $ request ) { $ kernelClosure = $ this -> legacyKernelClosure ; $ legacyKernel = $ kernelClosure ( ) ; $ logger = $ this -> logger ; $ legacyUser = $ legacyKernel -> runCallback ( static function ( ) use ( $ logger ) { foreach ( eZINI :: instance ( ) -> variable ( 'UserSettings' , 'SingleSignOnHandlerArray' ) as $ ssoHandlerName ) { $ className = 'eZ' . $ ssoHandlerName . 'SSOHandler' ; if ( ! class_exists ( $ className ) ) { if ( $ logger ) { $ logger -> error ( "Undefined legacy SSOHandler class: $className" ) ; } continue ; } $ ssoHandler = new $ className ( ) ; $ ssoUser = $ ssoHandler -> handleSSOLogin ( ) ; if ( ! $ ssoUser instanceof eZUser ) { continue ; } $ logger -> info ( "Matched user using eZ legacy SSO Handler: $className" ) ; return $ ssoUser ; } } , false , false ) ; if ( ! $ legacyUser instanceof eZUser ) { return [ '' , '' ] ; } $ user = new User ( $ this -> userService -> loadUser ( $ legacyUser -> attribute ( 'contentobject_id' ) ) , [ 'ROLE_USER' ] ) ; return [ $ user , $ user -> getPassword ( ) ] ; }
Iterates over legacy SSO handlers and pre - authenticates a user if a handler returns one .
45,784
public function onBuildKernelWebHandler ( PreBuildKernelWebHandlerEvent $ event ) { $ siteAccess = $ this -> container -> get ( 'ezpublish.siteaccess' ) ; $ request = $ event -> getRequest ( ) ; $ uriPart = [ ] ; switch ( $ siteAccess -> matchingType ) { case 'default' : $ legacyAccessType = eZSiteAccess :: TYPE_DEFAULT ; break ; case 'env' : $ legacyAccessType = eZSiteAccess :: TYPE_SERVER_VAR ; break ; case 'uri:map' : case 'uri:element' : case 'uri:text' : case 'uri:regexp' : $ legacyAccessType = eZSiteAccess :: TYPE_URI ; break ; case 'host:map' : case 'host:element' : case 'host:text' : case 'host:regexp' : $ legacyAccessType = eZSiteAccess :: TYPE_HTTP_HOST ; break ; case 'port' : $ legacyAccessType = eZSiteAccess :: TYPE_PORT ; break ; default : $ legacyAccessType = eZSiteAccess :: TYPE_CUSTOM ; } $ pathinfo = str_replace ( $ request -> attributes -> get ( 'viewParametersString' ) , '' , rawurldecode ( $ request -> getPathInfo ( ) ) ) ; $ fragmentPathInfo = implode ( '/' , $ this -> getFragmentPathItems ( ) ) ; if ( $ fragmentPathInfo !== '_fragment' ) { $ semanticPathinfo = $ fragmentPathInfo ; } else { $ semanticPathinfo = $ request -> attributes -> get ( 'semanticPathinfo' , $ pathinfo ) ; } $ pos = mb_strrpos ( $ pathinfo , $ semanticPathinfo ) ; if ( $ legacyAccessType !== eZSiteAccess :: TYPE_DEFAULT && $ pathinfo != $ semanticPathinfo && $ pos !== false ) { if ( $ pos === 0 ) { $ pos = mb_strlen ( $ pathinfo ) + 1 ; } $ uriPart = mb_substr ( $ pathinfo , 1 , $ pos - 1 ) ; $ uriPart = explode ( '/' , $ uriPart ) ; } if ( $ siteAccess -> matcher instanceof CompoundInterface ) { $ subMatchers = $ siteAccess -> matcher -> getSubMatchers ( ) ; if ( ! $ subMatchers ) { throw new \ RuntimeException ( 'Compound matcher used but not submatchers found.' ) ; } if ( \ count ( $ subMatchers ) == 2 && isset ( $ subMatchers [ 'Map\Host' ] ) && isset ( $ subMatchers [ 'Map\URI' ] ) ) { $ legacyAccessType = eZSiteAccess :: TYPE_HTTP_HOST_URI ; $ uriPart = [ $ subMatchers [ 'Map\URI' ] -> getMapKey ( ) ] ; } } $ event -> getParameters ( ) -> set ( 'siteaccess' , [ 'name' => $ siteAccess -> name , 'type' => $ legacyAccessType , 'uri_part' => $ uriPart , ] ) ; }
Maps matched siteaccess to the legacy parameters .
45,785
public function onKernelRequestSetup ( GetResponseEvent $ event ) { if ( $ event -> getRequestType ( ) == HttpKernelInterface :: MASTER_REQUEST ) { if ( $ this -> defaultSiteAccess !== 'setup' ) { return ; } $ request = $ event -> getRequest ( ) ; $ requestContext = $ this -> router -> getContext ( ) ; $ requestContext -> fromRequest ( $ request ) ; $ this -> router -> setContext ( $ requestContext ) ; $ setupURI = $ this -> router -> generate ( 'ezpublishSetup' ) ; if ( ( $ requestContext -> getBaseUrl ( ) . $ request -> getPathInfo ( ) ) === $ setupURI ) { return ; } $ event -> setResponse ( new RedirectResponse ( $ setupURI ) ) ; } }
Checks if it s needed to redirect to setup wizard .
45,786
final protected function getLegacyKernel ( ) { if ( ! isset ( $ this -> legacyKernelClosure ) ) { $ this -> legacyKernelClosure = $ this -> get ( 'ezpublish_legacy.kernel' ) ; } $ legacyKernelClosure = $ this -> legacyKernelClosure ; return $ legacyKernelClosure ( ) ; }
Returns the legacy kernel object .
45,787
public function regenerate ( $ destroy = false , $ lifetime = null ) { $ oldSessionId = $ this -> getId ( ) ; $ success = $ this -> innerSessionStorage -> regenerate ( $ destroy , $ lifetime ) ; $ newSessionId = $ this -> getId ( ) ; if ( $ success && ! $ destroy ) { $ kernelClosure = $ this -> legacyKernelClosure ; $ kernelClosure ( ) -> runCallback ( static function ( ) use ( $ oldSessionId , $ newSessionId ) { ezpEvent :: getInstance ( ) -> notify ( 'session/regenerate' , [ $ oldSessionId , $ newSessionId ] ) ; $ db = eZDB :: instance ( ) ; $ escOldKey = $ db -> escapeString ( $ oldSessionId ) ; $ escNewKey = $ db -> escapeString ( $ newSessionId ) ; $ escUserID = $ db -> escapeString ( eZSession :: userID ( ) ) ; eZSession :: triggerCallback ( 'regenerate_pre' , [ $ db , $ escNewKey , $ escOldKey , $ escUserID ] ) ; eZSession :: triggerCallback ( 'regenerate_post' , [ $ db , $ escNewKey , $ escOldKey , $ escUserID ] ) ; } , false , false ) ; } return $ success ; }
Ensures appropriate legacy events are sent when migrating the session .
45,788
public function setMetadataBag ( MetadataBag $ metaBag = null ) { if ( $ this -> innerSessionStorage instanceof NativeSessionStorage ) { $ this -> innerSessionStorage -> setMetadataBag ( $ metaBag ) ; } }
Below reimplementation of public methods from NativeSessionStorage .
45,789
public static function installAssets ( Event $ event ) { $ options = self :: getOptions ( $ event ) ; $ consoleDir = static :: getConsoleDir ( $ event , 'install assets' ) ; $ webDir = $ options [ 'symfony-web-dir' ] ; $ symlink = '' ; if ( $ options [ 'symfony-assets-install' ] === 'symlink' ) { $ symlink = '--symlink ' ; } elseif ( $ options [ 'symfony-assets-install' ] === 'relative' ) { $ symlink = '--symlink --relative ' ; } if ( $ consoleDir === null ) { return ; } if ( ! self :: isDir ( $ webDir , 'symfony-web-dir' ) ) { return ; } static :: executeCommand ( $ event , $ consoleDir , 'ezpublish:legacy:assets_install ' . $ symlink . escapeshellarg ( $ webDir ) ) ; }
Installs the legacy assets under the web root directory .
45,790
public function generateResponseFromModuleResult ( ezpKernelResult $ result ) { $ moduleResult = $ result -> getAttribute ( 'module_result' ) ; if ( isset ( $ this -> legacyLayout ) && ! $ this -> legacyMode && ! $ this -> legacyResultHasLayout ( $ result ) ) { $ moduleResult [ 'content' ] = $ result -> getContent ( ) ; $ response = $ this -> render ( $ this -> legacyLayout , [ 'module_result' => $ moduleResult ] ) ; $ response -> setModuleResult ( $ moduleResult ) ; } else { $ response = new LegacyResponse ( $ result -> getContent ( ) ) ; } if ( isset ( $ moduleResult [ 'errorCode' ] ) ) { if ( ! $ this -> legacyMode ) { if ( $ moduleResult [ 'errorCode' ] == 401 || $ moduleResult [ 'errorCode' ] == 403 ) { $ errorMessage = isset ( $ moduleResult [ 'errorMessage' ] ) ? $ moduleResult [ 'errorMessage' ] : 'Access denied' ; throw new AccessDeniedException ( $ errorMessage ) ; } if ( $ moduleResult [ 'errorCode' ] == 404 ) { $ errorMessage = isset ( $ moduleResult [ 'errorMessage' ] ) ? $ moduleResult [ 'errorMessage' ] : 'Not found' ; throw new NotFoundHttpException ( $ errorMessage , $ response ) ; } } $ response -> setStatusCode ( $ moduleResult [ 'errorCode' ] , isset ( $ moduleResult [ 'errorMessage' ] ) ? $ moduleResult [ 'errorMessage' ] : null ) ; } return $ response ; }
Generates LegacyResponse object from result returned by legacy kernel .
45,791
public function onBuildKernelHandler ( PreBuildKernelEvent $ event ) { $ sessionInfos = [ 'configured' => false , 'started' => false , 'name' => false , 'namespace' => false , 'has_previous' => false , 'storage' => false , ] ; if ( isset ( $ this -> session ) ) { $ request = $ this -> getCurrentRequest ( ) ; $ sessionInfos [ 'configured' ] = true ; $ sessionInfos [ 'name' ] = $ this -> session -> getName ( ) ; $ sessionInfos [ 'started' ] = $ this -> session -> isStarted ( ) ; $ sessionInfos [ 'namespace' ] = $ this -> sessionStorageKey ; $ sessionInfos [ 'has_previous' ] = isset ( $ request ) ? $ request -> hasPreviousSession ( ) : false ; $ sessionInfos [ 'storage' ] = $ this -> sessionStorage ; } $ legacyKernelParameters = $ event -> getParameters ( ) ; $ legacyKernelParameters -> set ( 'session' , $ sessionInfos ) ; $ sessionSettings = [ 'site.ini/Session/CookieTimeout' => false , 'site.ini/Session/CookiePath' => false , 'site.ini/Session/CookieDomain' => false , 'site.ini/Session/CookieSecure' => false , 'site.ini/Session/CookieHttponly' => false , ] ; $ legacyKernelParameters -> set ( 'injected-settings' , $ sessionSettings + ( array ) $ legacyKernelParameters -> get ( 'injected-settings' ) ) ; }
Adds the session settings to the parameters that will be injected into the legacy kernel .
45,792
public function updateLegacyURI ( Request $ request ) { $ viewParametersString = rtrim ( $ request -> attributes -> get ( 'semanticPathinfo' , $ request -> getPathinfo ( ) ) . $ request -> attributes -> get ( 'viewParametersString' ) , '/' ) ; $ uri = eZURI :: instance ( ) ; $ uri -> setURIString ( $ viewParametersString ) ; }
Fixes up legacy eZURI against current request .
45,793
public function getVariation ( Field $ field , VersionInfo $ versionInfo , $ variationName , array $ parameters = [ ] ) { $ variationIdentifier = "$field->id-$versionInfo->versionNo-$variationName" ; if ( isset ( $ this -> variations [ $ variationIdentifier ] ) ) { return $ this -> variations [ $ variationIdentifier ] ; } $ allAliasHandlers = & $ this -> aliasHandlers ; $ allVariations = & $ this -> variations ; return $ this -> getLegacyKernel ( ) -> runCallback ( static function ( ) use ( $ field , $ versionInfo , $ variationName , & $ allAliasHandlers , & $ allVariations , $ variationIdentifier ) { $ aliasHandlerIdentifier = "$field->id-$versionInfo->versionNo" ; if ( ! isset ( $ allAliasHandlers [ $ aliasHandlerIdentifier ] ) ) { $ allAliasHandlers [ $ aliasHandlerIdentifier ] = new eZImageAliasHandler ( eZContentObjectAttribute :: fetch ( $ field -> id , $ versionInfo -> versionNo ) ) ; } $ imageAliasHandler = $ allAliasHandlers [ $ aliasHandlerIdentifier ] ; $ aliasArray = $ imageAliasHandler -> imageAlias ( $ variationName ) ; if ( $ aliasArray === null ) { throw new InvalidVariationException ( $ variationName , 'image' ) ; } $ allVariations [ $ variationIdentifier ] = new ImageVariation ( [ 'name' => $ variationName , 'fileName' => $ aliasArray [ 'filename' ] , 'dirPath' => $ aliasArray [ 'dirpath' ] , 'fileSize' => isset ( $ aliasArray [ 'filesize' ] ) ? $ aliasArray [ 'filesize' ] : 0 , 'mimeType' => $ aliasArray [ 'mime_type' ] , 'lastModified' => new \ DateTime ( '@' . $ aliasArray [ 'timestamp' ] ) , 'uri' => $ aliasArray [ 'url' ] , 'width' => $ aliasArray [ 'width' ] , 'height' => $ aliasArray [ 'height' ] , 'imageId' => sprintf ( '%d-%d' , $ versionInfo -> contentInfo -> id , $ field -> id ) , ] ) ; return $ allVariations [ $ variationIdentifier ] ; } , false , false ) ; }
Returns an image variation object . Variation creation will be done through the legacy eZImageAliasHandler using the legacy kernel .
45,794
public function buildLegacyKernel ( $ legacyKernelHandler ) { $ legacyRootDir = $ this -> legacyRootDir ; $ webrootDir = $ this -> webrootDir ; $ eventDispatcher = $ this -> eventDispatcher ; $ logger = $ this -> logger ; $ that = $ this ; return static function ( ) use ( $ legacyKernelHandler , $ legacyRootDir , $ webrootDir , $ eventDispatcher , $ logger , $ that ) { if ( LegacyKernel :: hasInstance ( ) ) { return LegacyKernel :: instance ( ) ; } if ( $ legacyKernelHandler instanceof \ Closure ) { $ legacyKernelHandler = $ legacyKernelHandler ( ) ; } $ legacyKernel = new LegacyKernel ( $ legacyKernelHandler , $ legacyRootDir , $ webrootDir , $ logger ) ; if ( $ that -> getBuildEventsEnabled ( ) ) { $ eventDispatcher -> dispatch ( LegacyEvents :: POST_BUILD_LEGACY_KERNEL , new PostBuildKernelEvent ( $ legacyKernel , $ legacyKernelHandler ) ) ; } return $ legacyKernel ; } ; }
Builds up the legacy kernel and encapsulates it inside a closure allowing lazy loading .
45,795
public function buildLegacyKernelHandlerWeb ( $ webHandlerClass , array $ defaultLegacyOptions = [ ] ) { $ legacyRootDir = $ this -> legacyRootDir ; $ webrootDir = $ this -> webrootDir ; $ uriHelper = $ this -> uriHelper ; $ eventDispatcher = $ this -> eventDispatcher ; $ container = $ this -> container ; $ that = $ this ; return function ( ) use ( $ legacyRootDir , $ webrootDir , $ container , $ defaultLegacyOptions , $ webHandlerClass , $ uriHelper , $ eventDispatcher , $ that ) { if ( ! $ that -> getWebHandler ( ) ) { chdir ( $ legacyRootDir ) ; $ legacyParameters = new ParameterBag ( $ defaultLegacyOptions ) ; $ legacyParameters -> set ( 'service-container' , $ container ) ; $ request = $ this -> requestStack -> getCurrentRequest ( ) ; if ( $ that -> getBuildEventsEnabled ( ) ) { $ eventDispatcher -> dispatch ( LegacyEvents :: PRE_BUILD_LEGACY_KERNEL , new PreBuildKernelEvent ( $ legacyParameters ) ) ; $ eventDispatcher -> dispatch ( LegacyEvents :: PRE_BUILD_LEGACY_KERNEL_WEB , new PreBuildKernelWebHandlerEvent ( $ legacyParameters , $ request ) ) ; } $ interfaces = class_implements ( $ webHandlerClass ) ; if ( ! isset ( $ interfaces [ 'ezpKernelHandler' ] ) ) { throw new \ InvalidArgumentException ( 'A legacy kernel handler must be an instance of ezpKernelHandler.' ) ; } $ that -> setWebHandler ( new $ webHandlerClass ( $ legacyParameters -> all ( ) ) ) ; $ uriHelper -> updateLegacyURI ( $ request ) ; chdir ( $ webrootDir ) ; } return $ that -> getWebHandler ( ) ; } ; }
Builds up the legacy kernel web handler and encapsulates it inside a closure allowing lazy loading .
45,796
public function buildLegacyKernelHandlerCLI ( ) { $ legacyRootDir = $ this -> legacyRootDir ; $ eventDispatcher = $ this -> eventDispatcher ; $ container = $ this -> container ; $ that = $ this ; return static function ( ) use ( $ legacyRootDir , $ container , $ eventDispatcher , $ that ) { if ( ! $ that -> getCLIHandler ( ) ) { $ currentDir = getcwd ( ) ; chdir ( $ legacyRootDir ) ; $ legacyParameters = new ParameterBag ( $ container -> getParameter ( 'ezpublish_legacy.kernel_handler.cli.options' ) ) ; if ( $ that -> getBuildEventsEnabled ( ) ) { $ eventDispatcher -> dispatch ( LegacyEvents :: PRE_BUILD_LEGACY_KERNEL , new PreBuildKernelEvent ( $ legacyParameters ) ) ; } $ that -> setCLIHandler ( new CLIHandler ( $ legacyParameters -> all ( ) , $ container -> get ( 'ezpublish.siteaccess' ) , $ container ) ) ; chdir ( $ currentDir ) ; } return $ that -> getCLIHandler ( ) ; } ; }
Builds legacy kernel handler CLI .
45,797
public function buildLegacyKernelHandlerRest ( $ mvcConfiguration ) { $ legacyRootDir = $ this -> legacyRootDir ; $ webrootDir = $ this -> webrootDir ; $ uriHelper = $ this -> uriHelper ; $ eventDispatcher = $ this -> eventDispatcher ; $ container = $ this -> container ; $ that = $ this ; return function ( ) use ( $ legacyRootDir , $ webrootDir , $ container , $ uriHelper , $ eventDispatcher , $ that ) { if ( ! $ that -> getRestHandler ( ) ) { chdir ( $ legacyRootDir ) ; $ legacyParameters = new ParameterBag ( ) ; $ request = $ this -> requestStack -> getCurrentRequest ( ) ; if ( $ that -> getBuildEventsEnabled ( ) ) { $ eventDispatcher -> dispatch ( LegacyEvents :: PRE_BUILD_LEGACY_KERNEL , new PreBuildKernelEvent ( $ legacyParameters ) ) ; $ eventDispatcher -> dispatch ( LegacyEvents :: PRE_BUILD_LEGACY_KERNEL_WEB , new PreBuildKernelWebHandlerEvent ( $ legacyParameters , $ request ) ) ; } $ that -> setRestHandler ( new ezpKernelRest ( $ legacyParameters -> all ( ) , ResponseWriter :: class ) ) ; chdir ( $ webrootDir ) ; } return $ that -> getRestHandler ( ) ; } ; }
Builds the legacy kernel handler for the tree menu in admin interface .
45,798
public function resetKernel ( ) { if ( LegacyKernel :: hasInstance ( ) ) { $ kernelClosure = $ this -> container -> get ( 'ezpublish_legacy.kernel' ) ; $ this -> eventDispatcher -> dispatch ( LegacyEvents :: PRE_RESET_LEGACY_KERNEL , new PreResetLegacyKernelEvent ( $ kernelClosure ( ) ) ) ; } LegacyKernel :: resetInstance ( ) ; $ this -> webHandler = null ; $ this -> cliHandler = null ; $ this -> restHandler = null ; $ this -> container -> set ( 'ezpublish_legacy.kernel.lazy' , null ) ; $ this -> container -> set ( 'ezpublish_legacy.kernel_handler.web' , null ) ; $ this -> container -> set ( 'ezpublish_legacy.kernel_handler.cli' , null ) ; $ this -> container -> set ( 'ezpublish_legacy.kernel_handler.rest' , null ) ; }
Resets the legacy kernel instances from the container .
45,799
public function findOrFailByUuid ( $ uuid , $ columns = [ '*' ] ) { $ result = $ this -> findByUuid ( $ uuid , $ columns ) ; if ( is_array ( $ uuid ) ) { if ( count ( $ result ) == count ( array_unique ( $ uuid ) ) ) { return $ result ; } } elseif ( ! is_null ( $ result ) ) { return $ result ; } throw new NotFoundHttpException ( 'Resource \'' . class_basename ( get_class ( $ this -> model ) ) . '\' with given UUID ' . $ uuid . ' not found' ) ; }
Find a model by its UUID key or throw a not found exception .