idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
45,400
protected function requestAuthor ( ) { if ( ! empty ( $ this -> getComposerData ( ) -> authors ) ) { return $ this -> selectAuthors ( ) ; } $ nameQuestion = new Question ( 'Please enter your name: ' ) ; $ emailQuestion = new Question ( 'Please enter your e-mail address: ' ) ; $ this -> getOutput ( ) -> writeln ( '' ) ; $ this -> getOutput ( ) -> writeln ( '<info>Cannot determine the developer name ' . 'from project\'s composer.json file.</info>' ) ; $ this -> getOutput ( ) -> writeln ( "<comment>To automatically set the developer's " . "name and e-mail and avoid entering it on every generate:* " . "commands set the authors entry on your project's " . "composer.json file.</comment>" ) ; $ authorName = $ this -> getQuestionHelper ( ) -> ask ( $ this -> getInput ( ) , $ this -> getOutput ( ) , $ nameQuestion ) ; $ authorEmail = $ this -> getQuestionHelper ( ) -> ask ( $ this -> getInput ( ) , $ this -> getOutput ( ) , $ emailQuestion ) ; return compact ( 'authorName' , 'authorEmail' ) ; }
Asks the author name and e - mail and returns them
45,401
protected function selectAuthors ( ) { $ options = $ this -> getAuthorsAsOptions ( ) ; $ this -> getOutput ( ) -> writeln ( '' ) ; $ this -> getOutput ( ) -> writeln ( '<info>Multiple authors found on ' . 'project\'s composer.json file.</info>' ) ; $ question = new ChoiceQuestion ( 'Please select the author from the list above:' , $ options , 0 ) ; $ question -> setErrorMessage ( 'The choice %s is invalid.' ) ; $ selected = $ this -> getQuestionHelper ( ) -> ask ( $ this -> input , $ this -> output , $ question ) ; $ parts = explode ( '<' , $ selected ) ; return [ 'authorName' => trim ( $ parts [ 0 ] ) , 'authorEmail' => trim ( $ parts [ 1 ] , '>' ) , ] ; }
Requests user to select author form a list of composer authors and returns them .
45,402
public function run ( RunnableInterface $ command , callable $ func = null ) { if ( $ func ) { throw new \ Exception ( 'You cannot process passthru with a callable. Use another Runner instead.' ) ; } $ command = ( string ) $ command -> getCommandAssembler ( ) ; passthru ( $ command , $ status ) ; return $ this -> getResponseClass ( $ command , $ status , '' ) ; }
Passes through result of the command so no output is set
45,403
private function processApiMethod ( SfRequest $ request ) { $ content = $ request -> getContent ( ) ; if ( ! $ content ) { throw new MissingHttpContentException ( 'Missing HTTP content.' ) ; } $ query = @ json_decode ( $ content , true ) ; if ( false === $ query ) { throw JsonParseException :: create ( json_last_error ( ) ) ; } return $ this -> processApiQuery ( $ query ) ; }
Process API method
45,404
private function processApiQuery ( array $ query ) { $ query += array ( 'params' => array ( ) , 'id' => null ) ; if ( empty ( $ query [ 'method' ] ) ) { throw new MissingMethodException ( 'Missing "method" parameter in query.' ) ; } if ( $ query [ 'id' ] !== null && ! is_scalar ( $ query [ 'id' ] ) ) { throw new InvalidIdException ( 'The "id" parameter must be a scalar.' ) ; } if ( ! is_scalar ( $ query [ 'method' ] ) ) { throw new InvalidMethodException ( 'The "method" parameter must be a scalar.' ) ; } if ( ! is_array ( $ query [ 'params' ] ) ) { throw new InvalidParametersException ( 'Input parameters must be a array.' ) ; } $ this -> requestId = $ query [ 'id' ] ; $ apiResponse = $ this -> handler -> handle ( $ query [ 'method' ] , $ query [ 'params' ] ) ; if ( $ apiResponse instanceof EmptyResponseInterface ) { if ( $ apiResponse instanceof ResponseInterface ) { return new SfResponse ( '' , $ apiResponse -> getHttpStatusCode ( ) , $ apiResponse -> getHeaders ( ) -> all ( ) ) ; } else { return new SfResponse ( '' ) ; } } $ data = array ( 'jsonrpc' => self :: JSON_RPC_VERSION , 'result' => $ apiResponse -> getData ( ) , 'id' => $ query [ 'id' ] ) ; return new JsonResponse ( $ data , $ apiResponse -> getHttpStatusCode ( ) , $ apiResponse -> getHeaders ( ) -> all ( ) ) ; }
Process api query
45,405
private function createErrorResponse ( $ code , $ message = null , array $ data = [ ] ) { if ( ! $ message ) { $ messages = $ this -> handler -> getErrors ( ) -> getErrors ( ) ; $ message = isset ( $ messages [ $ code ] ) ? $ messages [ $ code ] : 'Error' ; } $ json = [ 'jsonrpc' => self :: JSON_RPC_VERSION , 'error' => [ 'code' => $ code , 'message' => $ message ] , 'id' => $ this -> requestId ] ; if ( $ data ) { $ json [ 'error' ] [ 'data' ] = $ data ; } return new JsonResponse ( $ json , 200 ) ; }
Create error response
45,406
public function createViolationErrorResponse ( ViolationListException $ exception ) { $ errorData = [ ] ; foreach ( $ exception -> getViolationList ( ) as $ violation ) { $ errorData [ $ violation -> getPropertyPath ( ) ] = $ violation -> getMessage ( ) ; } $ errors = $ this -> handler -> getErrors ( ) ; $ code = $ errors -> hasException ( $ exception ) ? $ errors -> getExceptionCode ( $ exception ) : 0 ; return $ this -> createErrorResponse ( $ code , null , $ errorData ) ; }
Create violation error response
45,407
public function head ( $ uri = null , $ expectedStatus = null ) { $ this -> setMethod ( 'HEAD' ) ; $ this -> setUri ( $ uri ) ; if ( ! is_null ( $ expectedStatus ) ) { $ this -> expectingStatusCode ( $ expectedStatus ) ; } return $ this ; }
Set the HTTP method to HEAD and the uri if any .
45,408
private function InitCategoryArticles ( ) { $ tblArticle = Article :: Schema ( ) -> Table ( ) ; $ sql = Access :: SqlBuilder ( ) ; $ orderBy = $ sql -> OrderList ( $ sql -> OrderDesc ( $ tblArticle -> Field ( 'Created' ) ) ) ; $ this -> articles = Article :: Schema ( ) -> FetchByCategory ( false , $ this -> category , $ orderBy , null , $ this -> ArticleOffset ( ) , $ this -> perPage ) ; $ this -> articlesTotal = Article :: Schema ( ) -> CountByCategory ( false , $ this -> category ) ; }
Initializes the article array by category
45,409
protected function RemovalObject ( ) { $ id = Request :: PostData ( 'delete' ) ; return $ id ? Article :: Schema ( ) -> ByID ( $ id ) : null ; }
Gets the object to remove in case there is any
45,410
protected function BackLink ( ) { if ( $ this -> category ) { return BackendRouter :: ModuleUrl ( new CategoryList ( ) , array ( 'archive' => $ this -> archive -> GetID ( ) ) ) ; } else { return BackendRouter :: ModuleUrl ( new ArchiveList ( ) ) ; } }
The backlink ; either links to the category list or the archive list
45,411
public static function setNewDirectoryMode ( string $ mode = '740' ) : void { static :: init ( ) ; static :: $ newDirectoryMode = \ preg_match ( '/^[0-7]{3}$/' , $ mode ) ? \ intval ( $ mode , 8 ) : 0740 ; }
Sets default mode for newly created directories
45,412
public static function setNewFileMode ( string $ mode = '740' ) : void { static :: init ( ) ; static :: $ newFileMode = \ preg_match ( '/^[0-7]{3}$/' , $ mode ) ? \ intval ( $ mode , 8 ) : 0740 ; }
Sets default mode for newly created files
45,413
public static function setNewSymbolicLinkMode ( string $ mode = '740' ) : void { static :: init ( ) ; static :: $ newSymlinkMode = \ preg_match ( '/^[0-7]{3}$/' , $ mode ) ? \ intval ( $ mode , 8 ) : 0740 ; }
Sets default mode for newly created symbolic links
45,414
protected function createDefaultStyles ( ) : styles \ Map { return new styles \ Map ( [ 'error' => new Style ( 'white' , 'red' ) , 'info' => new Style ( 'green' ) , 'comment' => new Style ( 'cyan' ) , 'important' => new Style ( 'red' ) , 'header' => new Style ( 'black' , 'cyan' ) ] ) ; }
Creates a default Map of Styles to be used by this Formatter .
45,415
protected function apply ( string $ text , bool $ decorated ) : string { return $ decorated && ! empty ( $ text ) ? $ this -> stack -> current ( ) -> apply ( $ text ) : $ text ; }
Applies formatting to the given text .
45,416
public function scopeOrder ( $ query ) { $ order = Input :: get ( 'order' , isset ( $ this -> order ) ? $ this -> order : 'id' ) ? : 'id' ; $ direction = Input :: get ( 'direction' , isset ( $ this -> direction ) ? $ this -> direction : 'desc' ) ? : 'desc' ; return $ query -> orderBy ( $ order , $ direction ) ; }
Scope a query to order by query properties
45,417
protected function parseUserInfo ( ) { if ( null === $ this -> userInfo ) { return ; } if ( false === strpos ( $ this -> userInfo , ':' ) ) { $ this -> setUser ( $ this -> userInfo ) ; return ; } list ( $ user , $ password ) = explode ( ':' , $ this -> userInfo , 2 ) ; $ this -> setUser ( $ user ) ; $ this -> setPassword ( $ password ) ; }
Parse the user info into username and password segments
45,418
public function getPort ( ) { if ( empty ( $ this -> port ) ) { if ( array_key_exists ( $ this -> scheme , static :: $ defaultPorts ) ) { return static :: $ defaultPorts [ $ this -> scheme ] ; } } return $ this -> port ; }
Return the URI port
45,419
public function parse ( $ uri ) { parent :: parse ( $ uri ) ; if ( empty ( $ this -> path ) ) { $ this -> path = '/' ; } return $ this ; }
Parse a URI string
45,420
public static function beforeSaveBody ( $ text ) { static :: correctParams ( ) ; $ webfilesSubdir = static :: $ webfilesSubdir ; $ webfilesSubdirOld = static :: $ webfilesSubdirOld ; $ baseUrl = Yii :: $ app -> urlManager -> getBaseUrl ( ) ; $ trTable = [ "src=\"{$baseUrl}/{$webfilesSubdirOld}" => "src=\"@{$webfilesSubdir}" , "src=\"{$baseUrl}/{$webfilesSubdir}" => "src=\"@{$webfilesSubdir}" , ] ; $ text = strtr ( $ text , $ trTable ) ; return $ text ; }
Prepare text to save after visual editor .
45,421
public static function uploadUrl ( $ path = '' , $ uploadsAlias = '@uploads' , $ webfilesurlAlias = 'uploads' ) { $ path = str_replace ( '\\' , '/' , $ path ) ; $ webroot = str_replace ( '\\' , '/' , Yii :: getAlias ( '@webroot' ) ) ; $ uploads = str_replace ( '\\' , '/' , Yii :: getAlias ( $ uploadsAlias ) ) ; $ subdir = str_replace ( $ uploads , '' , $ path ) ; $ web = Yii :: getAlias ( '@web' ) ; $ files = Yii :: getAlias ( $ webfilesurlAlias ) ; $ result = $ web . ( empty ( $ web ) ? '' : '/' ) . $ files . $ subdir ; return $ result ; }
Convert upload path to web URL . Work only if alias
45,422
public function create ( Environment $ environment ) { $ scheme = $ environment -> getRequestScheme ( ) ; $ host = $ environment -> getHost ( ) ; $ port = $ environment -> getPort ( ) ; $ query = $ environment -> getQueryString ( ) ; $ user = $ environment -> getAuthUser ( ) ; $ pass = $ environment -> getAuthPassword ( ) ; $ path = parse_url ( 'http://example.com' . $ environment -> getRequestUri ( ) , PHP_URL_PATH ) ; if ( $ path === false ) { throw new InvalidArgumentException ( 'Uri path must be a string' ) ; } return new Uri ( $ scheme , $ host , $ port , $ path , $ query , '' , $ user , $ pass ) ; }
Create instances of Uri object from instance of Environment object
45,423
final protected function _tableDefinition ( ) { $ annotation = Annotation :: getClass ( $ this ) ; $ fieldClass = new \ ReflectionClass ( '\\Gcs\Framework\Core\\Orm\\Entity\\Field' ) ; $ foreignKeyClass = new \ ReflectionClass ( '\\Gcs\Framework\Core\\Orm\\Entity\\ForeignKey' ) ; $ builderClass = new \ ReflectionClass ( '\\Gcs\Framework\Core\\Orm\\Builder' ) ; foreach ( $ annotation [ 'class' ] as $ annotationClass ) { $ instance = $ annotationClass [ 0 ] [ 'instance' ] ; switch ( $ annotationClass [ 0 ] [ 'annotation' ] ) { case 'Table' : $ this -> name ( $ instance -> name ) ; break ; case 'Form' : $ this -> form ( $ instance -> name ) ; break ; } } foreach ( $ annotation [ 'properties' ] as $ name => $ annotationProperties ) { foreach ( $ annotationProperties as $ annotationProperty ) { $ instance = $ annotationProperty [ 'instance' ] ; if ( $ annotationProperty [ 'annotation' ] == 'Column' ) { $ this -> field ( $ name ) -> type ( $ fieldClass -> getConstant ( $ instance -> type ) ) -> size ( $ instance -> size ) -> beNull ( $ instance -> null == 'true' ? true : false ) -> primary ( $ instance -> primary == 'true' ? true : false ) -> unique ( $ instance -> unique == 'true' ? true : false ) -> precision ( $ instance -> precision ) -> defaultValue ( $ instance -> default ) -> enum ( $ instance -> enum != '' ? explode ( ',' , $ instance -> enum ) : [ ] ) ; $ fieldType = $ fieldClass -> getConstant ( $ instance -> type ) ; if ( in_array ( $ fieldType , [ Field :: DATETIME , Field :: DATE , Field :: TIMESTAMP ] ) ) { $ this -> set ( $ name , new \ DateTime ( ) ) ; } } else { $ this -> field ( $ name ) -> foreign ( [ 'type' => $ foreignKeyClass -> getConstant ( $ instance -> type ) , 'reference' => explode ( '.' , $ instance -> to ) , 'current' => explode ( '.' , $ instance -> from ) , 'belong' => $ foreignKeyClass -> getConstant ( $ instance -> belong ) , 'join' => $ builderClass -> getConstant ( $ instance -> join ) , ] ) ; $ foreignType = $ foreignKeyClass -> getConstant ( $ instance -> type ) ; if ( in_array ( $ foreignType , [ ForeignKey :: MANY_TO_MANY , ForeignKey :: ONE_TO_MANY ] ) ) { $ this -> set ( $ name , new Collection ( ) ) ; } } } } }
Creation of the table
45,424
public function field ( $ name ) { $ this -> _fields [ '' . $ name . '' ] = new Field ( $ name , $ this -> _name ) ; return $ this -> _fields [ '' . $ name . '' ] ; }
add a field
45,425
public function getPrimary ( ) { foreach ( $ this -> _fields as $ key => $ field ) { if ( $ field -> primary == true ) { $ this -> _primary = $ key ; break ; } } }
Get primary key name
45,426
public function get ( $ key ) { if ( array_key_exists ( $ key , $ this -> _fields ) ) { if ( gettype ( $ this -> _fields [ '' . $ key . '' ] ) == 'object' ) { return $ this -> _fields [ '' . $ key . '' ] -> value ; } else { return $ this -> _fields [ '' . $ key . '' ] ; } } else { throw new MissingEntityException ( 'The field "' . $ key . '" doesn\'t exist in ' . $ this -> _name ) ; } }
return a field value
45,427
public function createAction ( Request $ request , $ type = 0 ) { $ manager = $ this -> get ( 'opifer.content.content_manager' ) ; if ( $ type ) { $ contentType = $ this -> get ( 'opifer.content.content_type_manager' ) -> getRepository ( ) -> find ( $ type ) ; $ content = $ this -> get ( 'opifer.eav.eav_manager' ) -> initializeEntity ( $ contentType -> getSchema ( ) ) ; $ content -> setContentType ( $ contentType ) ; } else { $ content = $ manager -> initialize ( ) ; } $ form = $ this -> createForm ( ContentType :: class , $ content ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ blockManager = $ this -> get ( 'opifer.content.block_manager' ) ; $ document = new DocumentBlock ( ) ; $ document -> setPublish ( true ) ; $ blockManager -> save ( $ document ) ; $ content -> setBlock ( $ document ) ; $ manager -> save ( $ content ) ; return $ this -> redirectToRoute ( 'opifer_content_contenteditor_design' , [ 'type' => 'content' , 'id' => $ content -> getId ( ) , 'rootVersion' => 0 , ] ) ; } return $ this -> render ( $ this -> getParameter ( 'opifer_content.content_new_view' ) , [ 'form' => $ form -> createView ( ) , ] ) ; }
Select the type of content the site and the language before actually creating a new content item .
45,428
public function detailsAction ( Request $ request , $ id ) { $ manager = $ this -> get ( 'opifer.content.content_manager' ) ; $ content = $ manager -> getRepository ( ) -> find ( $ id ) ; $ form = $ this -> createForm ( ContentType :: class , $ content ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ manager -> save ( $ content ) ; } return $ this -> render ( $ this -> getParameter ( 'opifer_content.content_details_view' ) , [ 'content' => $ content , 'form' => $ form -> createView ( ) ] ) ; }
Details action .
45,429
public function add ( string $ name , RepositoryFactoryInterface $ factory ) : void { $ this -> factories [ $ name ] = $ factory ; }
Add repository factory .
45,430
public function remove ( string $ name ) : void { if ( $ this -> has ( $ name ) ) { unset ( $ this -> factories [ $ name ] ) ; } }
Remove repository factory .
45,431
protected function publishDatabaseDriver ( ) { $ this -> publishes ( [ __DIR__ . '/DriverAssets/Database/migrations' => database_path ( 'migrations' ) , ] ) ; $ this -> publishes ( [ __DIR__ . '/DriverAssets/Database/seeds' => database_path ( 'seeds' ) , ] ) ; return $ this ; }
Publish database driver assets .
45,432
protected function executeImpl ( $ params ) { $ log = $ this -> log ; $ log -> debug ( "CmdHello: Parameters received: " . implode ( "," , $ params ) ) ; $ resultText = "[requested by " . $ this -> post [ "user_name" ] . "]" ; if ( empty ( $ params ) ) { $ resultText .= " You must specify at least one parameter!" ; } else { $ resultText .= " CmdHello Result: " ; } $ attachments = array ( ) ; foreach ( $ params as $ param ) { $ log -> debug ( "CmdHello: processing parameter $param" ) ; $ attachment = new SlackResultAttachment ( ) ; $ attachment -> setTitle ( "Processing $param" ) ; $ attachment -> setText ( "Hello $param !!" ) ; $ attachment -> setFallback ( "fallback text." ) ; $ attachment -> setPretext ( "pretext here." ) ; $ attachment -> setColor ( "#00ff00" ) ; $ fields = array ( ) ; $ fields [ ] = SlackResultAttachmentField :: withAttributes ( "Short Field" , "Short Field Value" ) ; $ fields [ ] = SlackResultAttachmentField :: withAttributes ( "This is a long field" , "this is a long Value" , FALSE ) ; $ attachment -> setFieldsArray ( $ fields ) ; $ attachments [ ] = $ attachment ; } $ this -> setResultText ( $ resultText ) ; $ this -> setSlackResultAttachments ( $ attachments ) ; }
Factory method to be implemented from \ SlackHookFramework \ AbstractCommand .
45,433
public function toList ( bool $ mutable ) : ArrayList { if ( $ mutable ) { return new MutableList ( array_values ( $ this -> data ) ) ; } else { return new ImmutableList ( array_values ( $ this -> data ) ) ; } }
Copy the values of this collection into a list . Keys are not preserved .
45,434
public function append ( Node $ node ) { if ( ! is_array ( $ this -> _children ) ) { $ this -> _children = [ ] ; } $ this -> _children [ ] = $ node ; return $ this ; }
Append a node to the list
45,435
static function plugins ( ) { if ( ! self :: isEnabledPlugins ( ) ) throw new \ Exception ( 'Using Plugins depends on Poirot/Ioc; that not exists currently.' ) ; if ( ! self :: $ pluginManager ) self :: $ pluginManager = new PluginsHttpHeader ; return self :: $ pluginManager ; }
Headers Plugin Manager
45,436
static function givePluginManager ( PluginsHttpHeader $ pluginsManager ) { if ( self :: $ pluginManager !== null ) throw new exImmutable ( 'Header Factory Has Plugin Manager, and can`t be changed.' ) ; self :: $ pluginManager = $ pluginsManager ; }
Set Headers Plugin Manager
45,437
public function forget ( string $ key ) : bool { $ key = $ this -> hashKey ( $ key ) ; if ( \ array_key_exists ( $ key , $ this -> cache ) ) { unset ( $ this -> cache [ $ key ] ) ; return true ; } return false ; }
Clear the cache for the given key Returns true on success or false on failure .
45,438
public function remember ( string $ key , callable $ callBack ) { $ existing = $ this -> get ( $ key ) ; if ( $ existing !== null ) { return $ existing ; } $ result = $ callBack ( ) ; return $ this -> put ( $ key , $ result ) ; }
Remembers the return value of the callback and returns that if available on next call .
45,439
public function get ( string $ key ) { $ key = $ this -> hashKey ( $ key ) ; if ( \ array_key_exists ( $ key , $ this -> cache ) ) { $ this -> hits ++ ; return $ this -> cache [ $ key ] ; } $ this -> misses ++ ; return null ; }
Retrieve an item from the cache .
45,440
public function put ( string $ key , $ value ) { $ this -> cache [ $ this -> hashKey ( $ key ) ] = $ value ; return $ value ; }
Push an item into the cache for a given URL Returns true on success or false on fail
45,441
public function handleHandleHttpRequestEvent ( HandleHttpRequestEvent $ event ) { $ event -> setResponse ( $ this -> requestHandler -> handle ( $ event -> getRequest ( ) ) ) ; }
Handle HandleHttpRequestEvent and create a response .
45,442
protected function shareInstancesInContainer ( ) { $ this -> container -> set ( [ Router :: class , IRouter :: class ] , $ this -> router ) ; $ this -> container -> set ( [ RequestHandler :: class , IRequestHandler :: class ] , $ this -> requestHandler ) ; }
Share instances in the container .
45,443
protected function loadRoutesFromConfig ( ) { $ config = $ this -> config -> getRaw ( 'routing' , [ ] ) ; $ this -> routerConfigurator -> processConfig ( $ this -> router , $ config ) ; }
Load routes from config .
45,444
public function output ( ) { if ( ! file_exists ( $ this -> _file ) ) throw new RuntimeException ( "Error loading template file: $this->_file." , 1 ) ; $ output = file_get_contents ( $ this -> _file ) ; foreach ( $ this -> _vars as $ key => $ value ) { $ tagToReplace = "[@$key]" ; $ output = str_replace ( $ tagToReplace , $ value , $ output ) ; } return $ output ; }
Outputs interpreted template content
45,445
public function make ( array $ data = [ ] , array $ validationRules = [ ] , array $ filterRules = [ ] ) { $ data = $ this -> sanitize ( $ data ) ; $ this -> validation_rules ( $ validationRules ) ; $ this -> filter_rules ( $ filterRules ) ; return $ this -> run ( $ data ) ; }
validate datas with validation rules and filter rules
45,446
public function make ( $ alias , array $ arguments = [ ] ) { foreach ( $ this -> _resolvers as $ resolver ) { $ binding = $ resolver -> make ( $ alias , $ arguments ) ; if ( $ binding !== null ) { return $ binding ; } } if ( array_key_exists ( $ alias , $ this -> _map ) ) { $ binding = $ this -> _map [ $ alias ] ; if ( is_callable ( $ binding ) ) { return call_user_func_array ( $ binding , $ arguments ) ; } elseif ( is_object ( $ binding ) ) { return $ binding ; } } else { $ binding = $ alias ; } $ reflector = new ReflectionClass ( $ binding ) ; if ( ! $ reflector -> isInstantiable ( ) ) { throw new InvalidArgumentException ( "$binding is not an instantiable class" ) ; } $ constructor = $ reflector -> getConstructor ( ) ; if ( empty ( $ constructor ) ) { return $ reflector -> newInstance ( ) ; } $ parameters = $ constructor -> getParameters ( ) ; $ values = [ ] ; for ( $ i = 0 ; $ i < count ( $ parameters ) ; $ i ++ ) { $ values [ ] = null ; } foreach ( $ arguments as $ argIndex => $ argument ) { if ( is_string ( $ argIndex ) ) { foreach ( $ parameters as $ paramIndex => $ parameter ) { if ( $ argIndex == $ parameter -> getName ( ) ) { $ values [ $ paramIndex ] = $ argument ; unset ( $ arguments [ $ argIndex ] ) ; break ; } } } } foreach ( $ parameters as $ paramIndex => $ parameter ) { if ( $ parameter -> getClass ( ) ) { foreach ( $ arguments as $ argIndex => $ argument ) { if ( is_object ( $ argument ) ) { if ( $ parameter -> getClass ( ) -> isInstance ( $ argument ) ) { $ values [ $ paramIndex ] = $ argument ; unset ( $ arguments [ $ argIndex ] ) ; break ; } } } } } foreach ( $ parameters as $ paramIndex => $ parameter ) { if ( ! isset ( $ values [ $ paramIndex ] ) ) { if ( $ parameter -> getClass ( ) ) { $ values [ $ paramIndex ] = $ this -> make ( $ parameter -> getClass ( ) -> getName ( ) ) ; } else { $ values [ $ paramIndex ] = array_shift ( $ arguments ) ; } } } return $ reflector -> newInstanceArgs ( $ values ) ; }
Gets or creates an instance of an alias
45,447
public function start ( ) { $ this -> _starttime = microtime ( true ) ; if ( extension_loaded ( 'xdebug' ) === false ) { return false ; } if ( is_null ( $ this -> _traceFile ) === true ) { $ this -> _traceFile = tempnam ( sys_get_temp_dir ( ) , 'PHPConsistent_' ) ; } ini_set ( 'xdebug.auto_trace' , 1 ) ; ini_set ( 'xdebug.trace_format' , 1 ) ; ini_set ( 'xdebug.collect_return' , 1 ) ; ini_set ( 'xdebug.collect_params' , 1 ) ; ini_set ( 'xdebug.trace_options' , 0 ) ; xdebug_start_trace ( $ this -> _traceFile ) ; if ( $ this -> _log === self :: LOG_TO_FIREPHP ) { ob_start ( ) ; break ; } if ( $ this -> _log !== self :: LOG_TO_PHPUNIT ) { register_shutdown_function ( array ( $ this , 'stop' ) ) ; register_shutdown_function ( array ( $ this , 'analyze' ) ) ; } return true ; }
Start PHPConsistent run
45,448
public function analyze ( ) { if ( ! file_exists ( $ this -> _traceFile ) ) { return false ; } $ this -> processFunctionCalls ( ) ; unlink ( $ this -> _traceFile ) ; if ( file_exists ( $ this -> _traceFile . '.xt' ) ) { unlink ( $ this -> _traceFile . '.xt' ) ; } if ( count ( $ this -> _failures ) > 0 ) { return $ this -> _failures ; } else { return array ( ) ; } }
Analyze PHPConsistent data from trace file
45,449
protected function addParamTypeFailure ( $ fileName , $ fileLine , $ calledFunction , $ parameterNumber , $ parameterName , $ expectedType , $ calledType ) { $ data = 'Invalid type calling ' . $ calledFunction . ' : parameter ' . $ parameterNumber . ' (' . $ parameterName . ') should be of type ' . $ expectedType . ' but got ' . $ calledType . ' instead' ; $ this -> reportFailure ( $ fileName , $ fileLine , $ data ) ; }
Add a failure about incorrect parameter type
45,450
protected function addParamNameMismatchFailure ( $ fileName , $ fileLine , $ calledFunction , $ parameterNumber , $ expectedName , $ calledName ) { $ data = 'Parameter names in function definition and docblock don\'t match when calling ' . $ calledFunction . ' : parameter ' . $ parameterNumber . ' (' . $ calledName . ') should be called ' . $ expectedName . ' according to docblock' ; $ this -> reportFailure ( $ fileName , $ fileLine , $ data ) ; }
Add a failure about mismatching parameter names
45,451
protected function addParamCountMismatchFailure ( $ fileName , $ fileLine , $ calledFunction , $ expectedCount , $ actualCount ) { $ data = 'Parameter count in function definition and docblock don\'t match when calling ' . $ calledFunction . ' : function has ' . $ actualCount . ' but should be ' . $ expectedCount . ' according to docblock' ; $ this -> reportFailure ( $ fileName , $ fileLine , $ data ) ; }
Add a failure about mismatching parameter count
45,452
protected function reportFailure ( $ fileName , $ fileLine , $ data ) { switch ( $ this -> _log ) { case self :: LOG_TO_FILE : file_put_contents ( $ this -> _logLocation , $ data . ' - in ' . $ fileName . ' (line ' . $ fileLine . ')' , FILE_APPEND ) ; break ; case self :: LOG_TO_FIREPHP : require_once 'FirePHPCore/FirePHP.class.php' ; $ firephp = FirePHP :: getInstance ( true ) ; $ firephp -> warn ( $ fileName . ' (line ' . $ fileLine . ')' , $ data ) ; break ; case self :: LOG_TO_PHPUNIT ; $ this -> _failures [ ] = array ( 'fileName' => $ fileName , 'fileLine' => $ fileLine , 'data' => $ data ) ; break ; } }
Output to the chosen reporting system
45,453
function & add_cell ( $ name = null ) { if ( ! $ name ) { $ name = uniqid ( microtime ( true ) , true ) ; } $ this -> cells [ $ name ] = new KHtml_Table_Cell ( ) ; return $ this -> cells [ $ name ] ; }
Add named cell to row of table
45,454
public static function getIdpsForSp ( $ spEntityId , $ metadataPath ) { $ idpEntries = Metadata :: getIdpMetadataEntries ( $ metadataPath ) ; return self :: getReducedIdpList ( $ idpEntries , $ metadataPath , $ spEntityId ) ; }
Takes the original idp entries and reduces them down to the ones the current SP is meant to see .
45,455
private function prepareStatement ( $ query , $ parameters ) { $ stmt = $ this -> db_connection -> prepare ( $ query ) ; if ( ! empty ( $ parameters ) ) { foreach ( $ parameters as $ key => $ val ) { $ stmt -> bindValue ( $ key , $ val ) ; } } return $ stmt ; }
Convert a string query and parameters to a PDO Statement
45,456
function deleteWhere ( $ table_name , $ where_with_placeholders , $ named_parameters ) { if ( empty ( $ where_with_placeholders ) || ! $ table_name ) { return false ; } $ sql_query = 'DELETE FROM ' . $ table_name . ' WHERE ' . $ where_with_placeholders ; Event :: dispatch ( EventData :: forBefore ( Event :: BEFORE_DELETE , $ table_name , $ named_parameters , $ sql_query ) ) ; try { $ stmt = $ this -> db_connection -> prepare ( $ sql_query ) ; if ( ! empty ( $ named_parameters ) ) { foreach ( $ named_parameters as $ k => $ v ) { $ stmt -> bindValue ( $ k , $ v ) ; } } $ stmt -> execute ( ) ; } catch ( Exception $ ex ) { Event :: dispatch ( EventData :: forException ( $ ex , $ sql_query , $ named_parameters ) ) ; throw new QueryException ( $ ex -> getMessage ( ) , $ ex -> getCode ( ) , $ ex ) ; } $ rows_affected = $ stmt -> rowCount ( ) ; Event :: dispatch ( EventData :: forAfter ( Event :: AFTER_DELETE , $ table_name , $ named_parameters , $ sql_query , $ rows_affected ) ) ; return $ rows_affected ; }
Performs an SQL delete with a WHERE clause
45,457
private function getEnumeratedParameterList ( $ parameter_name , $ param_array ) { $ result = [ ] ; if ( $ param_array ) { foreach ( $ param_array as $ k => $ v ) { $ result [ ':' . $ parameter_name . '_' . $ k ] = $ v ; } } return $ result ; }
Returns an array of named parameters
45,458
public function updateWhere ( $ table_name , $ update_values , $ where_with_placeholders , $ named_parameters = null ) { $ all_params = empty ( $ named_parameters ) ? $ update_values : array_merge ( $ update_values , $ named_parameters ) ; Event :: dispatch ( EventData :: forBefore ( Event :: BEFORE_UPDATE , $ table_name , $ all_params , $ where_with_placeholders ) , $ update_values ) ; $ q = $ this -> config -> getSystemIdentifierQuote ( ) ; $ sql_query = 'UPDATE ' . $ q . $ table_name . $ q . ' SET ' ; $ statement_params = [ ] ; $ null_params = [ ] ; foreach ( $ update_values as $ field_name => $ value ) { if ( $ field_name != 'id' ) { if ( strtolower ( $ value ) == 'null' || is_null ( $ value ) ) { $ sql_query .= "\n$q" . $ field_name . "$q = NULL," ; $ null_params [ $ field_name ] = 'NULL' ; } else { $ sql_query .= "\n$q" . $ field_name . "$q = :" . $ field_name . "," ; $ statement_params [ ':' . $ field_name ] = $ value ; } } } $ full_param_list = array_merge ( $ null_params , $ statement_params ) ; $ sql_query = substr ( $ sql_query , 0 , - 1 ) ; $ sql_query .= ' WHERE ' . $ where_with_placeholders ; if ( $ named_parameters ) { foreach ( $ named_parameters as $ param => $ val ) { $ statement_params [ $ param ] = $ val ; } } try { $ stmt = $ this -> db_connection -> prepare ( $ sql_query ) ; if ( $ statement_params ) { foreach ( $ statement_params as $ k => $ v ) { $ stmt -> bindValue ( $ k , $ v ) ; } } $ stmt -> execute ( ) ; } catch ( Exception $ ex ) { Event :: dispatch ( EventData :: forException ( $ ex , $ sql_query , $ full_param_list ) ) ; return false ; } $ rows_affected = $ stmt -> rowCount ( ) ; Event :: dispatch ( EventData :: forAfter ( Event :: AFTER_UPDATE , $ table_name , $ full_param_list , $ sql_query , $ rows_affected ) ) ; return $ rows_affected ; }
Performs an SQL update with a WHERE clause
45,459
public function render ( $ data ) { if ( isset ( $ data [ 'content' ] ) ) { $ this -> config ( [ 'content' => $ data [ 'content' ] ] ) ; $ content = new MenuContent ( $ this -> config ( ) , $ this -> _here ) ; $ group = isset ( $ data [ 'group' ] ) ? $ data [ 'group' ] : null ; $ contents = $ content -> render ( $ group ) ; $ this -> _active = $ this -> _active || $ content -> active ( ) ; $ this -> config ( 'wrapper.wrapper' , $ contents ) ; } if ( $ this -> _active ) { $ class = $ this -> config ( 'wrapper.class' ) . ' active' ; $ this -> config ( 'wrapper.class' , $ class ) ; } return $ this -> formatTemplate ( 'wrapper' , $ this -> config ( 'wrapper' ) ) ; }
Renders the menu wrapper and it s content .
45,460
function addAdresse ( $ params = array ( ) ) { $ index = count ( $ this -> coordonnees ) ; if ( isset ( $ params [ 'adresse' ] ) && $ params [ 'adresse' ] != '' ) { $ this -> coordonnees [ $ index ] [ 'adresse' ] = $ params [ 'adresse' ] ; } else { $ this -> coordonnees [ $ index ] [ 'adresse' ] = '' ; } if ( isset ( $ params [ 'link' ] ) && $ params [ 'link' ] != '' ) { $ this -> coordonnees [ $ index ] [ 'link' ] = $ params [ 'link' ] ; } else { $ this -> coordonnees [ $ index ] [ 'link' ] = '' ; } if ( isset ( $ params [ 'imageFlag' ] ) && $ params [ 'imageFlag' ] != '' ) { $ this -> coordonnees [ $ index ] [ 'imageFlag' ] = $ params [ 'imageFlag' ] ; } else { $ this -> coordonnees [ $ index ] [ 'imageFlag' ] = '' ; } if ( isset ( $ params [ 'longitude' ] ) && $ params [ 'longitude' ] != '' && isset ( $ params [ 'latitude' ] ) && $ params [ 'latitude' ] != '' ) { $ this -> coordonnees [ $ index ] [ 'longitude' ] = $ params [ 'longitude' ] ; $ this -> coordonnees [ $ index ] [ 'latitude' ] = $ params [ 'latitude' ] ; } if ( isset ( $ params [ 'setImageWidth' ] ) ) { $ this -> coordonnees [ $ index ] [ 'imageWidth' ] = $ params [ 'setImageWidth' ] ; } if ( isset ( $ params [ 'setImageHeight' ] ) ) { $ this -> coordonnees [ $ index ] [ 'imageHeight' ] = $ params [ 'setImageHeight' ] ; } if ( isset ( $ params [ 'pathToImageFlag' ] ) && $ params [ 'pathToImageFlag' ] != '' ) { $ this -> coordonnees [ $ index ] [ 'pathToImageFlag' ] = $ params [ 'pathToImageFlag' ] ; } else { $ this -> coordonnees [ $ index ] [ 'pathToImageFlag' ] = '' ; } }
Ajouter une adresse ?
45,461
public function getHTML ( ) { $ html = "<div id='" . $ this -> googleMapNameId . "' style='width: " . $ this -> googleMapWidth . "px; height: " . $ this -> googleMapHeight . "px; " . $ this -> divStyle . "'>Veuilliez patienter pendant le chargement de la carte...</div>" ; $ html .= "<script >load();</script>" ; $ html .= "<script >" ; if ( isset ( $ params [ 'urlImageIcon' ] ) && isset ( $ params [ 'pathImageIcon' ] ) ) { $ urlImage = $ params [ 'urlImageIcon' ] ; list ( $ imageSizeX , $ imageSizeY , $ typeImage , $ attrImage ) = getimagesize ( $ params [ 'pathImageIcon' ] ) ; $ html .= " var icon = new GIcon(); //icon.image = image; icon.image = \"$urlImage\"; //icon.shadow = \"https://labs.google.com/ridefinder/images/mm_20_shadow.png\"; icon.iconSize = new GSize($imageSizeX, $imageSizeY); icon.shadowSize = new GSize(22, 20); icon.iconAnchor = new GPoint(2, 24); icon.infoWindowAnchor = new GPoint(5, 1); var iconMarker = new GIcon(icon); " ; } else { $ html .= " var icon = new GIcon(); //icon.image = image; var iconMarker = new GIcon(icon); icon.image = \"https://labs.google.com/ridefinder/images/mm_20_red.png\"; //icon.shadow = \"https://labs.google.com/ridefinder/images/mm_20_shadow.png\"; icon.iconSize = new GSize(30, 24); icon.shadowSize = new GSize(22, 20); icon.iconAnchor = new GPoint(2, 24); icon.infoWindowAnchor = new GPoint(5, 1); " ; } $ html .= "</script>" ; if ( isset ( $ params [ 'listeCoordonnees' ] ) ) { $ html .= "<script >" ; foreach ( $ params [ 'listeCoordonnees' ] as $ indice => $ values ) { $ html .= " point$indice = new GLatLng(" . $ values [ 'latitude' ] . ", " . $ values [ 'longitude' ] . "); marker$indice = new GMarker(point$indice, iconMarker); overlay$indice = map.addOverlay(marker$indice); //marker$indice.openInfoWindowHtml(\"" . $ values [ 'libelle' ] . "\"); " ; if ( isset ( $ values [ 'jsCodeOnClickMarker' ] ) ) { $ html .= " function onClickFunction$indice(overlay, point){" . $ values [ 'jsCodeOnClickMarker' ] . "}" ; $ html .= "GEvent.addListener(marker$indice, 'click', onClickFunction$indice);" ; } if ( isset ( $ values [ 'jsCodeOnMouseOverMarker' ] ) ) { $ html .= "function onMouseOverFunction$indice(overlay, point){" . $ values [ 'jsOnMouseOverMarker' ] . "}" ; $ html .= "GEvent.addListener(marker$indice, 'mouseover', onMouseOverFunction$indice);" ; } if ( isset ( $ values [ 'jsCodeOnMouseOutMarker' ] ) ) { $ html .= "function onMouseOutFunction$indice(overlay, point){" . $ values [ 'jsCodeOnMouseOutMarker' ] . "}" ; $ html .= "GEvent.addListener(marker$indice, 'mouseout', onMouseOutFunction$indice);" ; } } $ html .= "</script>" ; } return $ html ; }
Affiche la carte Si l on veut rajouter des evenements a cette carte il faut ajouter le code des evenements apres l appel a cette fonction car c est ici que l on cree map
45,462
public function distance ( $ lat1 = 0 , $ lon1 = 0 , $ lat2 = 0 , $ lon2 = 0 ) { $ theta = $ lon1 - $ lon2 ; $ dist = sin ( _deg2rad ( $ lat1 ) ) * sin ( _deg2rad ( $ lat2 ) ) + cos ( _deg2rad ( $ lat1 ) ) * cos ( _deg2rad ( $ lat2 ) ) * cos ( _deg2rad ( $ theta ) ) ; $ dist = acos ( $ dist ) ; $ dist = _rad2deg ( $ dist ) ; $ dist = $ dist * 60 * 1.1515 ; $ dist = $ dist * 1.609344 ; return $ dist ; }
Calcul de distance
45,463
public function getActions ( ) { $ actions = [ ] ; foreach ( $ this -> data [ 'actions' ] as $ action ) { $ name = $ action [ 'name' ] ; $ time = isset ( $ action [ 'time' ] ) ? $ action [ 'time' ] : 0 ; if ( isset ( $ actions [ $ name ] ) ) { $ actions [ $ name ] [ 'count' ] += 1 ; $ actions [ $ name ] [ 'time' ] += $ time ; } else { $ actions [ $ name ] = [ 'name' => $ name , 'count' => 1 , 'time' => $ time ] ; } } return array_values ( $ actions ) ; }
Gets executed actions .
45,464
public function getProcessors ( ) { $ processors = [ ] ; foreach ( $ this -> data [ 'actions' ] as $ action ) { if ( isset ( $ action [ 'processors' ] ) ) { foreach ( $ action [ 'processors' ] as $ processor ) { $ id = $ processor [ 'id' ] ; $ time = isset ( $ processor [ 'time' ] ) ? $ processor [ 'time' ] : 0 ; if ( isset ( $ processors [ $ id ] ) ) { $ processors [ $ id ] [ 'count' ] += 1 ; $ processors [ $ id ] [ 'time' ] += $ time ; } else { $ processors [ $ id ] = [ 'id' => $ id , 'count' => 1 , 'time' => $ time ] ; } } } } return array_values ( $ processors ) ; }
Gets executed processors .
45,465
public function getProcessorCount ( ) { $ count = 0 ; foreach ( $ this -> data [ 'actions' ] as $ action ) { if ( isset ( $ action [ 'processors' ] ) ) { $ count += count ( $ action [ 'processors' ] ) ; } } return $ count ; }
Gets the number of executed processors .
45,466
public function getTotalTime ( ) { if ( null === $ this -> totalTime ) { $ this -> totalTime = 0 ; foreach ( $ this -> data [ 'actions' ] as $ action ) { if ( isset ( $ action [ 'time' ] ) ) { $ this -> totalTime += $ action [ 'time' ] ; } } foreach ( $ this -> data [ 'applicableCheckers' ] as $ applicableChecker ) { if ( isset ( $ applicableChecker [ 'time' ] ) ) { $ this -> totalTime += $ applicableChecker [ 'time' ] ; } } } return $ this -> totalTime ; }
Gets the total time of all executed actions .
45,467
protected function SaveElement ( ) { $ this -> form -> SetMethod ( $ this -> Value ( 'Method' ) ) ; $ this -> form -> SetSaveTo ( $ this -> Value ( 'SaveTo' ) ) ; $ this -> form -> SetSendFrom ( $ this -> Value ( 'SendFrom' ) ) ; $ this -> form -> SetSendTo ( $ this -> Value ( 'SendTo' ) ) ; $ this -> form -> SetRedirectUrl ( $ this -> selector -> Save ( $ this -> form -> GetRedirectUrl ( ) ) ) ; return $ this -> form ; }
Attaches properties and returns the form content
45,468
public function exists ( $ key , $ lifetime ) { if ( ! $ this -> cache_dir ) { $ this -> initializeCacheDir ( ) ; } if ( ! file_exists ( $ this -> cache_dir . $ key . ".html" ) ) { return false ; } $ file_lifetime = time ( ) - filectime ( $ this -> cache_dir . $ key . ".html" ) ; if ( $ file_lifetime > $ lifetime ) { $ this -> delete ( $ key ) ; return false ; } return true ; }
Returns true if cache with given key exists otherwise false If the cache has lived for longer than its life time destroy the cache
45,469
protected function prefill ( ) { if ( ! $ this -> prefill || $ this -> prefilled ) { return ; } try { $ this -> definitions = $ this -> getReadConnection ( ) -> hGetAll ( $ this -> hashName ) ; $ this -> prefilled = true ; } catch ( \ Exception $ exception ) { throw new RedisException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) , $ exception ) ; } }
Loads all container data from Redis
45,470
public function write ( $ message ) { $ written = false ; if ( $ this -> output_allowed ) { $ written = error_log ( $ message ) ; } return $ written ; }
Writes to the configured PHP error logger .
45,471
public static function get ( $ fileName , $ driverClass = null ) { $ configuration = new Configuration ( $ fileName , $ driverClass ) ; return $ configuration -> initialize ( ) ; }
Creates a ConfigurationInterface with passed arguments
45,472
private function driverClass ( ) { if ( null == $ this -> driverClass ) { $ this -> driverClass = $ this -> determineDriver ( $ this -> file ) ; } return $ this -> driverClass ; }
Returns the driver class to be initialized
45,473
private function determineDriver ( $ file ) { $ exception = new InvalidArgumentException ( "Cannot initialize the configuration driver. I could not determine " . "the correct driver class." ) ; if ( is_null ( $ file ) || ! is_string ( $ file ) ) { throw $ exception ; } $ nameDivision = explode ( '.' , $ file ) ; $ extension = strtolower ( end ( $ nameDivision ) ) ; if ( ! array_key_exists ( $ extension , $ this -> extensionToDriver ) ) { throw $ exception ; } return $ this -> extensionToDriver [ $ extension ] ; }
Tries to determine the driver class based on given file
45,474
private function composeFileName ( $ name ) { if ( is_null ( $ name ) ) { return $ name ; } $ ext = $ this -> determineExtension ( ) ; $ withExtension = $ this -> createName ( $ name , $ ext ) ; list ( $ found , $ fileName ) = $ this -> searchFor ( $ name , $ withExtension ) ; return $ found ? $ fileName : $ name ; }
Compose the filename with existing paths and return when match
45,475
private function determineExtension ( ) { $ ext = 'php' ; if ( in_array ( $ this -> driverClass , $ this -> extensionToDriver ) ) { $ map = array_flip ( $ this -> extensionToDriver ) ; $ ext = $ map [ $ this -> driverClass ] ; } return $ ext ; }
Determine the extension based on the driver class
45,476
private function searchFor ( $ name , $ withExtension ) { $ found = false ; $ fileName = $ name ; foreach ( self :: $ paths as $ path ) { $ fileName = "{$path}/$withExtension" ; if ( is_file ( $ fileName ) ) { $ found = true ; break ; } } return [ $ found , $ fileName ] ; }
Search for name in the list of paths
45,477
private function createConfigurationDriver ( ) { $ reflection = new \ ReflectionClass ( $ this -> driverClass ( ) ) ; $ config = $ reflection -> hasMethod ( '__construct' ) ? $ reflection -> newInstanceArgs ( [ $ this -> file ] ) : $ reflection -> newInstance ( ) ; return $ config ; }
Creates the configuration driver from current properties
45,478
private function setProperties ( $ option ) { $ priority = isset ( $ option [ 2 ] ) ? $ option [ 2 ] : 0 ; $ this -> driverClass = isset ( $ option [ 1 ] ) ? $ option [ 1 ] : null ; $ this -> file = isset ( $ option [ 0 ] ) ? $ this -> composeFileName ( $ option [ 0 ] ) : null ; return $ priority ; }
Sets the file and driver class
45,479
private function fixOptions ( ) { $ options = ( is_array ( $ this -> file ) ) ? $ this -> file : [ [ $ this -> file ] ] ; return $ options ; }
Fixes the file for initialization
45,480
public function createAction ( ) { $ success = null ; $ this -> paragraphLayout ( ) ; $ request = $ this -> getRequest ( ) ; $ data = $ request -> getPost ( ) ; $ service = $ this -> getServiceLocator ( ) ; $ model = $ service -> get ( 'Grid\User\Model\User\Model' ) ; $ form = $ service -> get ( 'Form' ) -> get ( 'Grid\User\PasswordChangeRequest\Create' ) ; if ( $ request -> isPost ( ) ) { $ form -> setData ( $ data ) ; if ( $ form -> isValid ( ) ) { $ data = $ form -> getData ( 'email' ) ; $ user = $ model -> findByEmail ( $ data [ 'email' ] ) ; if ( ! empty ( $ user ) && $ user -> state != UserStructure :: STATE_BANNED ) { $ change = $ this -> url ( ) -> fromRoute ( 'Grid\User\PasswordChangeRequest\Resolve' , array ( 'locale' => ( string ) $ this -> locale ( ) , 'hash' => $ this -> getServiceLocator ( ) -> get ( 'Grid\User\Model\ConfirmHash' ) -> create ( $ user -> email ) , ) ) ; $ this -> getServiceLocator ( ) -> get ( 'Grid\Mail\Model\Template\Sender' ) -> prepare ( array ( 'template' => 'user.forgotten-password' , 'locale' => $ user -> locale , ) ) -> send ( array ( 'email' => $ user -> email , 'display_name' => $ user -> displayName , 'change_url' => $ change , ) , array ( $ user -> email => $ user -> displayName , ) ) ; $ success = true ; } else { $ success = false ; } } else { $ success = false ; } } if ( $ success === true || $ success === false ) { $ this -> messenger ( ) -> add ( 'user.form.passwordRequest.success' , 'user' , Message :: LEVEL_INFO ) ; } return new MetaContent ( 'user.passwordChangeRequest' , array ( 'form' => $ form , ) ) ; }
Create a password - request
45,481
public function resolveAction ( ) { $ success = null ; $ failed = null ; $ service = $ this -> getServiceLocator ( ) ; $ userModel = $ service -> get ( 'Grid\User\Model\User\Model' ) ; $ confirm = $ service -> get ( 'Grid\User\Model\ConfirmHash' ) ; $ hash = $ this -> params ( ) -> fromRoute ( 'hash' ) ; if ( $ confirm -> has ( $ hash ) && ( $ email = $ confirm -> find ( $ hash ) ) ) { $ user = $ userModel -> findByEmail ( $ email ) ; if ( ! empty ( $ user ) && $ user -> state != UserStructure :: STATE_BANNED ) { $ request = $ this -> getRequest ( ) ; $ data = $ request -> getPost ( ) ; $ form = $ service -> get ( 'Form' ) -> get ( 'Grid\User\PasswordChangeRequest\Resolve' ) ; if ( $ request -> isPost ( ) ) { $ form -> setData ( $ data ) ; if ( $ form -> isValid ( ) ) { $ data = $ form -> getData ( ) ; $ user -> state = UserStructure :: STATE_ACTIVE ; $ user -> confirmed = true ; $ user -> password = $ data [ 'password' ] ; if ( $ user -> save ( ) ) { $ confirm -> delete ( $ hash ) ; $ success = true ; } } else { $ success = false ; } } } else { $ failed = true ; } } else { $ failed = true ; } if ( $ failed === true ) { $ this -> messenger ( ) -> add ( 'user.form.passwordChange.failed' , 'user' , Message :: LEVEL_ERROR ) ; return $ this -> redirect ( ) -> toRoute ( 'Grid\User\PasswordChangeRequest\Create' , array ( 'locale' => ( string ) $ this -> locale ( ) , 'returnUri' => '/' , ) ) ; } if ( $ success === true ) { $ this -> messenger ( ) -> add ( 'user.form.passwordChange.success' , 'user' , Message :: LEVEL_INFO ) ; return $ this -> redirect ( ) -> toRoute ( 'Grid\User\Authentication\Login' , array ( 'locale' => ( string ) $ this -> locale ( ) , 'returnUri' => '/' , ) ) ; } if ( $ success === false ) { $ this -> messenger ( ) -> add ( 'user.form.passwordChange.resolve.failed' , 'user' , Message :: LEVEL_ERROR ) ; } $ this -> paragraphLayout ( ) ; return new MetaContent ( 'user.passwordChangeRequest' , array ( 'success' => $ success , 'form' => $ form , ) ) ; }
Resolve a password - request
45,482
public function getSitetreeManager ( ) { if ( empty ( static :: $ _sitetreeManager ) ) { $ module = Yii :: $ app -> getModule ( $ this -> sitetreeModuleUniqueId ) ; if ( ! empty ( $ module ) && $ module instanceof UniModule ) { $ mgr = $ module -> getDataModel ( $ this -> sitetreeManagerAlias ) ; if ( empty ( $ mgr -> rules ) ) $ mgr -> rules = Yii :: $ app -> urlManager -> rules ; static :: $ _sitetreeManager = $ mgr ; } } return static :: $ _sitetreeManager ; }
Find Sitetree module from system loaded modules
45,483
public function getInputFilterSpecification ( ) : array { return [ 'api_key' => [ 'required' => false , 'filters' => [ [ 'name' => StripTags :: class ] , [ 'name' => StringTrim :: class ] , ] , 'validators' => [ [ 'name' => StringLength :: class , 'options' => [ 'encoding' => 'UTF-8' , 'min' => 10 , 'max' => 20 , ] ] , [ 'name' => Alnum :: class ] , ] , ] , 'blog' => [ 'required' => false , 'filters' => [ [ 'name' => StripTags :: class ] , [ 'name' => StringTrim :: class ] , ] , 'validators' => [ [ 'name' => StringLength :: class , 'options' => [ 'encoding' => 'UTF-8' , 'min' => 10 , 'max' => 255 , ] ] , [ 'name' => Uri :: class , 'options' => [ 'uriHandler' => Http :: class , 'allowRelative' => false , ] ] , ] , ] , ] ; }
Get input filter for elements .
45,484
private function initDefaultAnnotationReader ( ) { if ( null !== self :: $ defaultAnnotationReader ) { return ; } $ docParser = new DocParser ( ) ; $ docParser -> setImports ( [ 'Bits' => 'KonstantinKuklin\\DoctrineCompressedFields\\Annotation' , ] ) ; $ docParser -> setIgnoreNotImportedAnnotations ( true ) ; $ reader = new AnnotationReader ( $ docParser ) ; AnnotationRegistry :: registerFile ( __DIR__ . '/../Annotation/Hub.php' ) ; AnnotationRegistry :: registerFile ( __DIR__ . '/../Annotation/Mask.php' ) ; $ reader = new CachedReader ( $ reader , new VoidCache ( ) ) ; self :: $ defaultAnnotationReader = $ reader ; }
Create default annotation reader for extension
45,485
public function listAction ( ) { $ repository = $ this -> get ( 'phlexible_media_template.template_manager' ) ; $ allTemplates = $ repository -> findAll ( ) ; $ templates = [ ] ; foreach ( $ allTemplates as $ template ) { if ( substr ( $ template -> getKey ( ) , 0 , 4 ) === '_mm_' ) { continue ; } $ templates [ ] = [ 'key' => $ template -> getKey ( ) , 'type' => $ template -> getType ( ) , ] ; } return new JsonResponse ( [ 'templates' => $ templates ] ) ; }
List mediatemplates .
45,486
public function createAction ( Request $ request ) { $ templateRepository = $ this -> get ( 'phlexible_media_template.template_manager' ) ; $ type = $ request -> get ( 'type' ) ; $ key = $ request -> get ( 'key' ) ; switch ( $ type ) { case 'image' : $ template = new ImageTemplate ( ) ; $ template -> setCache ( false ) ; break ; case 'video' : $ template = new VideoTemplate ( ) ; $ template -> setCache ( true ) ; break ; case 'audio' : $ template = new AudioTemplate ( ) ; $ template -> setCache ( true ) ; break ; default : throw new InvalidArgumentException ( "Unknown template type $type" ) ; } $ template -> setKey ( $ key ) ; $ templateRepository -> updateTemplate ( $ template ) ; return new ResultResponse ( true , 'New "' . $ type . '" template "' . $ key . '" created.' ) ; }
Create mediatemplate .
45,487
public function findDistinctByRootId ( $ rootId ) { $ qb = $ this -> createQueryBuilder ( 'l' ) -> andWhere ( 'l.rootId = :rootId' ) -> groupBy ( 'l.rootVersion' ) -> setParameter ( 'rootId' , $ rootId ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; }
Returns a list of BlockLogEntries distinct by rootId
45,488
public function getLogEntriesRoot ( $ entity , $ rootVersion = null ) { $ q = $ this -> getLogEntriesQueryRoot ( $ entity , $ rootVersion ) ; return $ q -> getResult ( ) ; }
Loads all log entries for the given entity
45,489
public function getLogEntriesQueryRoot ( $ entity , $ rootVersion = null ) { $ wrapped = new EntityWrapper ( $ entity , $ this -> _em ) ; $ objectClass = $ wrapped -> getMetadata ( ) -> name ; $ meta = $ this -> getClassMetadata ( ) ; $ dql = "SELECT log FROM {$meta->name} log" ; $ dql .= " WHERE log.objectId = :objectId" ; $ dql .= " AND log.objectClass = :objectClass" ; $ dql .= " AND log.rootVersion <= :rootVersion" ; $ dql .= " ORDER BY log.version DESC" ; $ objectId = $ wrapped -> getIdentifier ( ) ; $ q = $ this -> _em -> createQuery ( $ dql ) ; $ q -> setParameters ( compact ( 'objectId' , 'objectClass' , 'rootVersion' ) ) ; return $ q ; }
Get the query for loading of log entries
45,490
public function actionIndex ( $ slug ) { $ this -> trigger ( self :: EVENT_BEFORE_VIEW_SHOW ) ; $ data [ 'slug' ] = $ slug ; $ data [ 'route' ] = '/' . $ this -> getRoute ( ) ; $ videoFinder = new VideoFinder ( ) ; $ data [ 'video' ] = $ videoFinder -> findBySlug ( $ slug ) ; if ( empty ( $ data [ 'video' ] ) ) { throw new NotFoundHttpException ( 'The requested page does not exist.' ) ; } $ settings = Yii :: $ app -> settings -> getAll ( ) ; $ settings [ 'videos' ] = Module :: getInstance ( ) -> settings -> getAll ( ) ; if ( $ data [ 'video' ] [ 'template' ] !== '' ) { $ template = $ data [ 'video' ] [ 'template' ] ; } else { $ template = 'view' ; } Event :: on ( self :: class , self :: EVENT_AFTER_VIEW_SHOW , [ \ ytubes \ videos \ events \ UpdateCountersEvent :: class , 'onClickVideo' ] , $ data ) ; $ this -> trigger ( self :: EVENT_AFTER_VIEW_SHOW ) ; return $ this -> render ( $ template , [ 'data' => $ data , 'settings' => $ settings ] ) ; }
Displays a single Videos model .
45,491
private function getExpireTime ( array $ expires = [ 'm' => 1 ] ) : int { $ expireTime = \ time ( ) ; if ( \ is_array ( $ expires ) ) { if ( isset ( $ expires [ 'y' ] ) ) { $ expireTime += \ intval ( 0 + $ expires [ 'y' ] ) * 60 * 60 * 24 * 365 ; } if ( isset ( $ expires [ 'm' ] ) ) { $ expireTime += \ intval ( 0 + $ expires [ 'm' ] ) * 60 * 60 * 24 * 30 ; } if ( isset ( $ expires [ 'd' ] ) ) { $ expireTime += \ intval ( 0 + $ expires [ 'd' ] ) * 60 * 60 * 24 ; } if ( isset ( $ expires [ 'h' ] ) ) { $ expireTime += \ intval ( 0 + $ expires [ 'h' ] ) * 60 * 60 ; } if ( isset ( $ expires [ 'i' ] ) ) { $ expireTime += \ intval ( 0 + $ expires [ 'i' ] ) * 60 ; } if ( isset ( $ expires [ 's' ] ) ) { $ expireTime += \ intval ( 0 + $ expires [ 's' ] ) ; } } return $ expireTime ; }
Calculates cookie expire time
45,492
public function get ( string $ variableName = null , int $ type = Variables :: TYPE_STRING ) { if ( $ variableName === null ) { throw new BadMethodCallException ( 'Variable name must be specified' ) ; } if ( isset ( $ this -> variables [ $ variableName ] ) ) { return $ this -> cast ( $ this -> variables [ $ variableName ] , $ type ) ; } return $ this -> cast ( null , $ type ) ; }
Returns COOKIE variable s value . If variable doesn t exist method returns default value for specified type .
45,493
public function set ( string $ variableName = null , $ variableValue = null , array $ expires = [ 'm' => 1 ] , bool $ encrypted = true ) : Cookie { if ( $ variableName === null ) { throw new BadMethodCallException ( 'Variable name must be specified' ) ; } \ setcookie ( $ variableName , $ encrypted === true ? $ variableValue : $ variableValue , $ this -> getExpireTime ( $ expires ) , $ this -> getPath ( ) , $ this -> getDomain ( ) , $ this -> isSecure ( ) , $ this -> isHttpOnly ( ) ) ; $ this -> variables [ $ variableName ] = $ variableValue ; return static :: $ instance ; }
Sets COOKIE variable .
45,494
public function executeCommand ( string $ cmd , array $ arguments = [ ] , array $ options = [ ] ) { $ options = array_replace ( [ 'overrideExitCode' => null , 'exceptionMessage' => 'There was an error while executing the command.' , 'returnString' => false , 'implodeSeparator' => PHP_EOL , 'postCommand' => '' ] , $ options ) ; foreach ( $ arguments as $ arg ) { $ cmd .= ' ' . escapeshellarg ( $ arg ) ; } $ cmd .= $ options [ 'postCommand' ] ; exec ( $ cmd , $ output , $ status ) ; $ status = $ status && $ options [ 'overrideExitCode' ] ? $ options [ 'overrideExitCode' ] : $ status ; $ this -> _lastExecutedCommand [ 'cmd' ] = $ cmd ; $ this -> _lastExecutedCommand [ 'arguments' ] = $ arguments ; $ this -> _lastExecutedCommand [ 'options' ] = $ options ; $ this -> _lastExecutedCommand [ 'output' ] = $ output ; $ this -> _lastExecutedCommand [ 'exitCode' ] = $ status ; if ( $ status ) { throw CommandException :: create ( $ options [ 'exceptionMessage' ] , $ options [ 'overrideExitCode' ] ? $ options [ 'overrideExitCode' ] : $ status , $ output , $ cmd , $ arguments ) ; } return $ options [ 'returnString' ] ? implode ( $ options [ 'implodeSeparator' ] , $ output ) : $ output ; }
Executes a Command .
45,495
public function mkdir ( string $ dir , array $ options = [ ] ) : SystemService { $ options = array_replace ( [ 'mode' => 0777 , 'recursive' => true , 'context' => null ] , $ options ) ; if ( file_exists ( $ dir ) ) { if ( ! is_dir ( $ dir ) ) { throw NotADirectoryException :: create ( 'Can\'t create directory "' . $ dir . '" because it exists and it\'s not a directory.' ) ; } return $ this ; } $ args = [ $ dir , $ options [ 'mode' ] , $ options [ 'recursive' ] ] ; if ( $ options [ 'context' ] !== null ) { $ args [ ] = $ options [ 'context' ] ; } if ( ! @ mkdir ( ... $ args ) ) { $ lastError = $ this -> getLastPhpError ( ) ; throw IOException :: create ( 'Couldn\'t create directory "' . $ dir . '". PHP Error: ' . print_r ( $ lastError , true ) ) ; } return $ this ; }
Creates a directory . If it already exists it doesn t throw an exception .
45,496
public function rm ( string $ fileOrDirectory , array $ options = [ ] ) : SystemService { $ options = array_replace ( [ 'force' => false , 'recursive' => false , 'context' => null , 'skipIfAlreadyRemoved' => true ] , $ options ) ; if ( ! file_exists ( $ fileOrDirectory ) && $ options [ 'skipIfAlreadyRemoved' ] ) { return $ this ; } $ args = [ $ fileOrDirectory ] ; if ( $ options [ 'context' ] !== null ) { $ args [ ] = $ options [ 'context' ] ; } if ( is_dir ( $ fileOrDirectory ) && ! is_link ( $ fileOrDirectory ) ) { if ( ! $ options [ 'force' ] ) { throw CantRemoveDirectoryException :: create ( '"' . $ fileOrDirectory . '" is a directory. If you really want to remove it, ' . 'set the "force" option to "true".' ) ; } if ( $ options [ 'recursive' ] ) { $ elements = $ this -> scandir ( $ fileOrDirectory , [ 'recursive' => true , 'context' => $ options [ 'context' ] , 'skipDots' => true , 'skipSymlinks' => true ] ) ; foreach ( $ elements as $ e ) { $ this -> rm ( $ e , $ options ) ; } } if ( ! @ rmdir ( ... $ args ) ) { throw IOException :: create ( 'Couldn\'t remove directory "' . $ fileOrDirectory . '". Last PHP Error: ' . print_r ( $ this -> getLastPhpError ( ) , true ) ) ; } } else if ( ! @ unlink ( ... $ args ) ) { throw IOException :: create ( 'Couldn\'t remove file or symlink "' . $ fileOrDirectory . '". Last PHP Error: ' . print_r ( $ this -> getLastPhpError ( ) , true ) ) ; } return $ this ; }
Removes a file symlink or directory . It removes directories if option force is true . If it s a directory and option force is false it throws an exception . Also it removes directories recursively . If file symlink or directory already does not exist it does NOT throw an exception .
45,497
public function scandir ( string $ dir , array $ options = [ ] ) { $ options = array_replace ( [ 'sort' => SCANDIR_SORT_NONE , 'context' => null , 'recursive' => false , 'skipDots' => true , 'skipSymlinks' => false ] , $ options ) ; if ( ! $ options [ 'skipSymlinks' ] && is_link ( $ dir ) ) { $ dir = @ readlink ( $ dir ) ; } $ args = [ $ dir , $ options [ 'sort' ] ] ; if ( $ options [ 'context' ] ) { $ args [ ] = $ options [ 'context' ] ; } if ( ( $ tmp = @ scandir ( ... $ args ) ) === false ) { throw IOException :: create ( 'Couldn\'t scan directory "' . $ dir . '". Last PHP Error: ' . print_r ( $ this -> getLastPhpError ( ) , true ) ) ; } if ( $ options [ 'skipDots' ] ) { $ tmp = array_diff ( $ tmp , array ( '.' , '..' ) ) ; } $ result = [ ] ; foreach ( $ tmp as $ f ) { $ f = $ dir . '/' . $ f ; if ( $ options [ 'skipSymlinks' ] && is_link ( $ f ) ) { continue ; } $ result [ ] = $ f ; if ( $ options [ 'recursive' ] && is_dir ( $ f ) ) { $ result = array_merge ( $ result , $ this -> scandir ( $ f , $ options ) ) ; } } $ tmp = null ; return array_unique ( $ result ) ; }
Scans a directory and returns an array of files symlinks and directories .
45,498
public function getRoutes ( ) { $ router_factory = new RouterFactory ; $ router = $ router_factory -> newInstance ( ) ; $ routes_file = $ this -> getAppResourcePath ( 'config/routes.php' ) ; if ( file_exists ( $ routes_file ) ) { include_once ( $ routes_file ) ; } else { $ router -> add ( null , '/' ) ; $ router -> add ( null , '/{controller}' ) ; $ router -> add ( null , '/{controller}/{action}' ) ; $ router -> add ( null , '/{controller}/{action}/{id}' ) ; } $ this -> router = $ router ; }
What routes have been configured for this app?
45,499
protected function addPrompts ( array $ options = [ ] ) { $ resolver = $ this -> getConfigResolver ( ) ; $ optionNames = [ ] ; foreach ( $ options as $ key => $ value ) { if ( is_string ( $ value ) ) { $ optionNames [ ] = $ value ; $ this -> promptConfig [ $ key ] = $ resolver -> resolve ( [ ] ) ; continue ; } if ( is_array ( $ value ) ) { $ optionNames [ ] = $ key ; $ this -> promptConfig [ $ key ] = $ resolver -> resolve ( $ value ) ; continue ; } throw new \ InvalidArgumentException ( "Invalid value passed into `addPrompts`." ) ; } $ this -> consolePrompts = array_unique ( array_merge ( $ this -> consolePrompts , $ optionNames ) ) ; foreach ( $ optionNames as $ option ) { if ( $ this -> getDefinition ( ) -> hasOption ( $ option ) ) { continue ; } $ this -> addOption ( $ option , null , InputOption :: VALUE_OPTIONAL , $ this -> promptConfig [ $ option ] [ 'description' ] ) ; } return $ this ; }
Add prompts through a key value array of option names = > their configuration . The configuration is optional .