idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
24,500
public function setRunnable ( $ runnable ) { if ( self :: isRunnableOk ( $ runnable ) ) { $ this -> runnable = $ runnable ; } else { $ this -> fatalError ( Thread :: FUNCTION_NOT_CALLABLE ) ; } }
Sets the callback
24,501
public function isAlive ( ) { $ pid = pcntl_waitpid ( $ this -> _pid , $ status , WNOHANG ) ; $ this -> result = unserialize ( trim ( socket_read ( $ this -> sockets [ 1 ] , $ this -> message_length ) ) ) ; socket_close ( $ this -> sockets [ 1 ] ) ; return ( $ pid === 0 ) ; }
Checks if the child thread is alive
24,502
public function start ( $ arguments ) { if ( socket_create_pair ( AF_UNIX , SOCK_STREAM , 0 , $ this -> sockets ) === false ) { throw new \ Exception ( socket_strerror ( socket_last_error ( ) ) ) ; } $ pid = @ pcntl_fork ( ) ; if ( $ pid == - 1 ) { $ this -> fatalError ( Thread :: COULD_NOT_FORK ) ; } if ( $ pid ) { $ this -> _pid = $ pid ; } else { pcntl_signal ( SIGTERM , array ( $ this , 'handleSignal' ) ) ; if ( ! empty ( $ arguments ) ) { $ results = call_user_func_array ( $ this -> runnable , $ arguments ) ; } else { $ results = call_user_func ( $ this -> runnable ) ; } $ data = serialize ( $ results ) ; socket_write ( $ this -> sockets [ 0 ] , str_pad ( $ data , $ this -> message_length ) , $ this -> message_length ) ; socket_close ( $ this -> sockets [ 0 ] ) ; exit ( 0 ) ; } }
Starts the thread all the parameters are passed to the callback function
24,503
public function stop ( $ signal = SIGKILL , $ wait = false ) { if ( $ this -> isAlive ( ) ) { posix_kill ( $ this -> _pid , $ signal ) ; if ( $ wait ) { pcntl_waitpid ( $ this -> _pid , $ status = 0 ) ; } } }
Attempts to stop the thread returns true on success and false otherwise
24,504
public function profile ( ) { $ userId = $ this -> Auth -> user ( 'id' ) ; if ( ! $ userId ) { $ this -> Flash -> error ( __d ( 'community' , 'You are not logged in' ) ) ; $ this -> redirect ( $ this -> Auth -> getConfig ( 'loginAction' ) ) ; } $ this -> set ( 'user' , $ this -> Users -> get ( $ userId , [ 'contain' => 'Groups' ] ) ) -> set ( 'page_title' , __d ( 'community' , 'Edit profile' ) ) ; }
Default profile page action .
24,505
private function _getUser ( $ id , $ token ) { return $ this -> Users -> find ( ) -> where ( [ 'id' => $ id , 'token' => $ token ] ) -> first ( ) ; }
Get user by id and activation token .
24,506
public function buildLink ( string $ protocol = null , string $ host = null , $ path = null , array $ query = null , string $ fragment = null ) : string { if ( empty ( $ protocol ) ) { $ protocol = ( array_key_exists ( 'HTTPS' , $ _SERVER ) && ! empty ( $ _SERVER [ 'HTTPS' ] ) ? 'https' : 'http' ) ; } if ( empty ( $ host ) ) { $ host = $ _SERVER [ 'HTTP_HOST' ] ; } $ link = "$protocol://$host/" ; if ( ! empty ( $ path ) ) { if ( is_string ( $ path ) ) { $ link .= $ path ; } elseif ( is_array ( $ path ) ) { $ path = $ this -> pathHelper -> joinArray ( $ path ) ; $ link .= $ path ; } else { $ type = gettype ( $ path ) ; throw new InvalidArgumentException ( "Expected a the path argument to be of type string or array, $type given!" , 1530398563 ) ; } } if ( ! empty ( $ query ) ) { $ link .= '?' . array_keys ( $ query ) [ 0 ] . '=' . array_shift ( $ query ) ; foreach ( $ query as $ key => $ value ) { $ link .= "&$key=$value" ; } } if ( ! empty ( $ fragment ) ) { $ link .= "#$fragment" ; } return $ link ; }
Build an URL by the given arguments .
24,507
protected function getGroupByKey ( $ group , $ key , $ value ) { if ( ! is_string ( $ group ) && is_callable ( $ group ) ) { return $ group ( $ value , $ key ) ; } return Util :: dataGet ( $ value , $ group ) ; }
Get the group by key value .
24,508
public function getPropertyValue ( $ object , $ name ) { $ property = new ReflectionProperty ( $ object , $ name ) ; $ property -> setAccessible ( true ) ; return $ property -> getValue ( $ object ) ; }
Get the value of a non - public property .
24,509
public function invokeMethod ( $ object , $ name , array $ args = [ ] ) { $ method = new ReflectionMethod ( $ object , $ name ) ; $ method -> setAccessible ( true ) ; if ( empty ( $ args ) ) { return $ method -> invoke ( $ object ) ; } return $ method -> invokeArgs ( $ object , $ args ) ; }
Invoke a non - public method
24,510
public function invokeStaticMethod ( $ class , $ name , array $ args = [ ] ) { $ method = new ReflectionMethod ( $ class , $ name ) ; $ method -> setAccessible ( true ) ; if ( empty ( $ args ) ) { return $ method -> invoke ( null ) ; } return $ method -> invokeArgs ( null , $ args ) ; }
Invoke a non - public static method
24,511
protected function createTree ( & $ keyParts , TreeNode $ rootNode ) : TreeNode { if ( ! count ( $ keyParts ) ) { return $ rootNode ; } $ newKey = array_shift ( $ keyParts ) ; $ newNode = new self ( $ rootNode , $ newKey , null , $ rootNode -> getKeyDelimiter ( ) ) ; $ rootNode -> addChild ( $ newNode ) ; return $ this -> createTree ( $ keyParts , $ newNode ) ; }
recursive way to build tree structure
24,512
public static function extend ( $ name , callable $ callable = null ) { if ( ! is_array ( $ name ) ) { if ( null === $ callable ) { throw new \ InvalidArgumentException ( "A callable must be given as second parameter if the first is not an array." ) ; } self :: $ extensions [ $ name ] = $ callable ; return ; } foreach ( $ name as $ method => $ callable ) { if ( ! is_callable ( $ callable ) ) { throw new \ InvalidArgumentException ( "The values of an array passed to the extend() method must be callables." ) ; } self :: $ extensions [ $ method ] = $ callable ; } }
Registers an additional static method .
24,513
public function viewURI ( ProcessBuilder $ processBuilder , $ uri ) { $ proc = $ processBuilder -> setPrefix ( $ this -> _browserCommand ) -> setArguments ( [ $ uri ] ) -> getProcess ( ) ; $ proc -> setTty ( true ) -> run ( ) ; return $ proc ; }
View the given URI using the symfony process builder to build the symfony process to execute .
24,514
public function installAction ( ) { $ connection = ConnectionManager :: create ( $ _SESSION [ 'db' ] ) ; $ this -> loadMigrations ( ) ; $ m = new Migrator ; $ m -> migrate ( 'up' ) ; $ admin = new User ( $ _SESSION [ 'admin' ] + [ 'name' => $ _SESSION [ 'admin' ] [ 'username' ] , 'group_id' => 1 ] ) ; $ admin -> save ( ) ; $ this -> set ( "config" , $ this -> makeConfig ( ) ) ; $ seeder = new Seeder ; $ seeder -> seed ( ) ; unset ( $ _SESSION [ 'db' ] , $ _SESSION [ 'admin' ] ) ; $ this -> title ( "Complete" ) ; return $ this -> render ( "complete.phtml" ) ; }
Migrate database and create admin account .
24,515
protected function makeConfig ( ) { $ config = [ "<?php" , "return [" , " 'environment' => \"production\"," , " 'db' => [" , " 'production' => [" ] ; if ( $ _SESSION [ 'db' ] [ 'driver' ] == "pdo_pgsql" || $ _SESSION [ 'db' ] [ 'driver' ] == "pdo_mysql" ) { $ config [ ] = " 'driver' => \"{$_SESSION['db']['driver']}\"," ; $ config [ ] = " 'host' => \"{$_SESSION['db']['host']}\"," ; $ config [ ] = " 'user' => \"{$_SESSION['db']['user']}\"," ; $ config [ ] = " 'password' => \"{$_SESSION['db']['password']}\"," ; $ config [ ] = " 'dbname' => \"{$_SESSION['db']['dbname']}\"," ; $ config [ ] = " 'prefix' => ''" ; } elseif ( $ _SESSION [ 'db' ] [ 'driver' ] == "pdo_sqlite" ) { $ config [ ] = " 'path' => \"{$_SESSION['db']['path']}\"" ; } $ config [ ] = " ]" ; $ config [ ] = " ]" ; $ config [ ] = "];" ; return htmlentities ( implode ( PHP_EOL , $ config ) ) ; }
Create the configuration file contents .
24,516
public static function inner ( string $ fromAlias , string $ to , string $ toAlias , string $ condition ) : Join { return new self ( self :: MODE_INNER , $ fromAlias , $ to , $ toAlias , $ condition ) ; }
Create inner mode
24,517
public static function left ( string $ fromAlias , string $ to , string $ toAlias , string $ condition ) : Join { return new self ( self :: MODE_LEFT , $ fromAlias , $ to , $ toAlias , $ condition ) ; }
Create left mode
24,518
public function getList ( array $ options = array ( ) ) { $ sql = 'SELECT *' ; if ( ! empty ( $ options [ 'count' ] ) ) { $ sql = 'SELECT COUNT(credential_id)' ; } $ sql .= ' FROM module_gapi_credential WHERE credential_id IS NOT NULL' ; $ conditions = array ( ) ; if ( isset ( $ options [ 'type' ] ) ) { $ sql .= ' AND type=?' ; $ conditions [ ] = $ options [ 'type' ] ; } $ allowed_order = array ( 'asc' , 'desc' ) ; $ allowed_sort = array ( 'name' , 'credential_id' , 'created' , 'modified' , 'type' ) ; if ( isset ( $ options [ 'sort' ] ) && in_array ( $ options [ 'sort' ] , $ allowed_sort ) && isset ( $ options [ 'order' ] ) && in_array ( $ options [ 'order' ] , $ allowed_order ) ) { $ sql .= " ORDER BY {$options['sort']} {$options['order']}" ; } else { $ sql .= ' ORDER BY created DESC' ; } if ( ! empty ( $ options [ 'limit' ] ) ) { $ sql .= ' LIMIT ' . implode ( ',' , array_map ( 'intval' , $ options [ 'limit' ] ) ) ; } if ( empty ( $ options [ 'count' ] ) ) { $ fetch_options = array ( 'index' => 'credential_id' , 'unserialize' => 'data' ) ; $ result = $ this -> db -> fetchAll ( $ sql , $ conditions , $ fetch_options ) ; } else { $ result = ( int ) $ this -> db -> fetchColumn ( $ sql , $ conditions ) ; } return $ result ; }
Returns an array of credentials or counts them
24,519
public function deleteService ( $ id ) { $ data = $ this -> get ( $ id ) ; if ( empty ( $ data ) ) { return false ; } if ( ! $ this -> delete ( $ id ) ) { return false ; } $ file = gplcart_file_absolute ( $ data [ 'data' ] [ 'file' ] ) ; if ( file_exists ( $ file ) ) { unlink ( $ file ) ; } return true ; }
Delete Service credential
24,520
public function update ( $ id , array $ data ) { $ data [ 'modified' ] = GC_TIME ; return ( bool ) $ this -> db -> update ( 'module_gapi_credential' , $ data , array ( 'credential_id' => $ id ) ) ; }
Updates a credential
24,521
public function getHandlers ( ) { $ handlers = array ( 'key' => array ( 'name' => $ this -> translation -> text ( 'API key' ) , 'handlers' => array ( 'delete' => array ( __CLASS__ , 'delete' ) , 'edit' => array ( 'gplcart\\modules\\gapi\\controllers\\Credential' , 'editKeyCredential' ) ) ) , 'oauth' => array ( 'name' => $ this -> translation -> text ( 'OAuth client ID' ) , 'handlers' => array ( 'delete' => array ( __CLASS__ , 'delete' ) , 'edit' => array ( 'gplcart\\modules\\gapi\\controllers\\Credential' , 'editOauthCredential' ) ) ) , 'service' => array ( 'name' => $ this -> translation -> text ( 'Service account key' ) , 'handlers' => array ( 'delete' => array ( __CLASS__ , 'deleteService' ) , 'edit' => array ( 'gplcart\\modules\\gapi\\controllers\\Credential' , 'editServiceCredential' ) ) ) ) ; $ this -> hook -> attach ( 'module.gapi.credential.handlers' , $ handlers ) ; return $ handlers ; }
Returns an array of credential handlers
24,522
public function callHandler ( $ handler_id , $ name , array $ arguments = array ( ) ) { return Handler :: call ( $ this -> getHandlers ( ) , $ handler_id , $ name , $ arguments ) ; }
Call a credential handler
24,523
public function validate ( $ subject ) : bool { if ( \ is_array ( $ this -> schema [ 'items' ] ) ) { $ schemaFirstKey = \ array_keys ( $ this -> schema [ 'items' ] ) [ 0 ] ; $ schemaType = \ is_int ( $ schemaFirstKey ) ? 'array' : 'object' ; if ( ( $ schemaType === 'object' ) && ! $ this -> validateItemsSchemaObject ( $ subject , $ this -> schema ) ) { return false ; } if ( $ schemaType === 'array' && ! $ this -> validateItemsSchemaArray ( $ subject , $ this -> schema ) ) { return false ; } } return true ; }
Validates subject against items
24,524
protected function cleanupOldBackups ( $ rollbackDir ) { $ finder = $ this -> getOldInstallationFinder ( $ rollbackDir ) ; $ fileSystem = new Filesystem ; foreach ( $ finder as $ file ) { $ file = ( string ) $ file ; $ this -> getIO ( ) -> writeError ( '<info>Removing: ' . $ file . '</info>' ) ; $ fileSystem -> remove ( $ file ) ; } }
Clean the backup directory .
24,525
protected function getBaseUrl ( ) { if ( isset ( $ this -> baseUrl ) ) { return $ this -> baseUrl ; } $ this -> baseUrl = $ this -> container -> getParameter ( 'tenside.self_update.base_url' ) ; if ( false === strpos ( $ this -> baseUrl , '://' ) ) { $ this -> baseUrl = ( extension_loaded ( 'openssl' ) ? 'https' : 'http' ) . '://' . $ this -> baseUrl ; } return $ this -> baseUrl ; }
Retrieve the base url for obtaining the latest version and phar files .
24,526
protected function determineRemoteFilename ( $ updateVersion ) { if ( preg_match ( '{^[0-9a-f]{40}$}' , $ updateVersion ) ) { return $ this -> getBaseUrl ( ) . '/' . $ this -> getPharName ( ) ; } return sprintf ( '%s/download/%s/%s' , $ this -> getBaseUrl ( ) , $ updateVersion , $ this -> getPharName ( ) ) ; }
Calculate the remote filename from a version .
24,527
protected function determineLocalFileName ( ) { if ( false !== ( $ localFilename = realpath ( $ _SERVER [ 'argv' ] [ 0 ] ) ) ) { return $ localFilename ; } if ( $ localFilename = \ Phar :: running ( false ) ) { return $ localFilename ; } return $ _SERVER [ 'argv' ] [ 0 ] ; }
Determine the local file name of the current running phar .
24,528
public function filterBy ( string $ name , $ value ) : AbstractRepository { $ this -> filters [ $ name ] = $ value ; return $ this ; }
Set new list filter .
24,529
public function setFilters ( array $ filters ) : AbstractRepository { foreach ( $ filters as $ f => $ v ) { $ this -> filterBy ( $ f , $ v ) ; } return $ this ; }
Set list filters .
24,530
public function orderBy ( ? string $ name , string $ type = self :: ORDER_ASC ) : AbstractRepository { $ this -> sorter [ 'name' ] = $ name ; $ this -> sorter [ 'type' ] = $ type ; return $ this ; }
Set list ordering .
24,531
public function createAction ( Request $ request ) { $ entity = new Post ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ this -> processVideo ( $ entity ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_post_show' , array ( 'id' => $ entity -> getId ( ) ) ) ) ; } else { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'warning' , $ this -> get ( 'translator' ) -> trans ( 'save_fail' ) ) ; } return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
Creates a new Post entity .
24,532
public function connect ( ) { $ arrParams = [ 'mysql:host=' . $ this -> host , 'dbname=' . $ this -> database , 'charset=' . $ this -> charset , ] ; $ this -> db = PdoSingleton :: getInstance ( ) -> getConnection ( $ arrParams , $ this -> username , $ this -> password ) ; }
Connect to MySql DB using constant params
24,533
public function getTableColumns ( ) : array { if ( ! $ this -> isTableNameSet ( ) ) { return [ ] ; } $ sql = "SHOW COLUMNS FROM `" . $ this -> tableName . "`" ; $ stmt = $ this -> db -> query ( $ sql ) ; $ arrResult = $ stmt -> fetchAll ( PDO :: FETCH_ASSOC ) ; return $ arrResult ; }
Returns Columns in table
24,534
public function save ( ) : bool { if ( ! $ this -> isTableNameSet ( ) ) { return false ; } $ pkName = $ this -> primaryKey ; if ( ( int ) $ this -> $ pkName > 0 ) { $ this -> updateEntry ( ) ; } else { $ this -> createEntry ( ) ; } return true ; }
Save if new update if primary key isset
24,535
public function delete ( ) : int { $ sql = "DELETE FROM `" . $ this -> tableName . "` " . "WHERE `" . $ this -> primaryKey . "` = '" . $ this -> id . "';" ; return $ this -> db -> exec ( $ sql ) ; }
Delete Row from DB Table
24,536
protected function createEntry ( ) { $ arrColumns = $ this -> getTableColumns ( ) ; $ arrColumnNames = [ ] ; $ arrColumnTypes = [ ] ; foreach ( $ arrColumns as $ column ) { $ arrColumnNames [ ] = $ column [ 'Field' ] ; $ arrColumnTypes [ ] = $ column [ 'Type' ] ; } $ sql = 'INSERT INTO `' . $ this -> tableName . '` ' . '(`' . implode ( '`, `' , $ arrColumnNames ) . '`) ' . 'VALUES ' . '(:' . implode ( ', :' , $ arrColumnNames ) . ')' ; $ arrInsert = [ ] ; for ( $ i = 0 ; $ i < count ( $ arrColumnNames ) ; $ i ++ ) { $ name = $ arrColumnNames [ $ i ] ; $ value = isset ( $ this -> $ name ) ? $ this -> $ name : "" ; if ( substr ( $ arrColumnTypes [ $ i ] , 0 , 3 ) == 'int' ) { $ value = ( int ) $ value ; } elseif ( $ arrColumnTypes [ $ i ] == 'datetime' ) { $ value = strftime ( "%Y-%m-%d %H:%M:%S" , strtotime ( $ value ) ) ; } $ arrInsert [ ':' . $ name ] = $ value ; } $ this -> db -> beginTransaction ( ) ; $ stmt = $ this -> db -> prepare ( $ sql ) ; try { $ stmt -> execute ( $ arrInsert ) ; $ this -> db -> commit ( ) ; } catch ( PDOException $ ex ) { $ this -> db -> rollBack ( ) ; $ this -> log -> critical ( "Could not save to mysql" . PHP_EOL . $ sql . PHP_EOL . print_r ( $ arrInsert , true ) . PHP_EOL . $ ex -> getMessage ( ) ) ; } }
Inset a new Row into DB Table
24,537
public function getAllRows ( array $ arrWhat = [ '*' ] , array $ arrWhere = [ ] , array $ arrOrder = [ '`id` ASC' ] , array $ arrLimit = [ ] ) : array { if ( count ( $ arrWhat ) < 1 ) { throw new Exception ( 'Missing MySQL Select Params' ) ; } $ strWhere = "" ; $ strOrder = "" ; $ strLimit = "" ; if ( count ( $ arrWhere ) > 0 ) { $ strWhere = "WHERE " . implode ( " AND " , $ arrWhere ) . " " ; } if ( count ( $ arrOrder ) > 0 ) { $ strOrder = "ORDER BY " . implode ( ", " , $ arrOrder ) . " " ; } if ( count ( $ arrLimit ) > 0 ) { $ strLimit = "LIMIT " . implode ( "," , $ arrLimit ) . " " ; } $ what = "`" . implode ( $ arrWhat , "`,`" ) . "`" ; $ sql = "SELECT " . $ what . " " . "FROM `" . $ this -> tableName . "` " . $ strWhere . $ strOrder . $ strLimit ; $ stmt = $ this -> db -> query ( $ sql ) ; $ arrRows = $ stmt -> fetchAll ( PDO :: FETCH_ASSOC ) ; if ( $ arrRows === false ) { throw new Exception ( 'failed to execute ' . $ sql ) ; } return $ arrRows ; }
Simple SELECT Query no transactions fetch multiple entries
24,538
public function loadByPrepStmt ( array $ arrWhat = [ '*' ] , array $ arrWhere = [ ] , array $ arrOrder = [ '`id` ASC' ] , array $ arrLimit = [ ] ) : array { $ arrStmt = [ ] ; $ strWhere = "" ; if ( count ( $ arrWhere ) > 0 ) { $ arrWhereNames = [ ] ; foreach ( $ arrWhere as $ key => $ val ) { if ( is_array ( $ val ) && $ val [ 'operator' ] === "like" ) { $ arrWhereNames [ ] = "`" . $ key . "` LIKE :" . $ key ; $ arrStmt [ ':' . $ key ] = $ val [ 'value' ] ; } else { $ arrWhereNames [ ] = "`" . $ key . "` = :" . $ key ; $ arrStmt [ ':' . $ key ] = $ val ; } } $ strWhere = "WHERE " . implode ( " AND " , $ arrWhereNames ) . " " ; } $ strOrder = "" ; if ( count ( $ arrOrder ) > 0 ) { $ strOrder = "ORDER BY " . implode ( ", " , $ arrOrder ) . " " ; } $ strLimit = "" ; if ( isset ( $ arrLimit [ 0 ] ) ) { $ strLimit .= "LIMIT " . ( ( int ) $ arrLimit [ 0 ] ) ; } if ( isset ( $ arrLimit [ 1 ] ) ) { $ strLimit .= "," . ( ( int ) $ arrLimit [ 1 ] ) ; } $ sql = "SELECT " . implode ( "," , $ arrWhat ) . " FROM `" . $ this -> tableName . "` " . $ strWhere . $ strOrder . $ strLimit ; $ stmt = $ this -> db -> prepare ( $ sql ) ; $ stmt -> execute ( $ arrStmt ) ; $ result = $ stmt -> fetchAll ( PDO :: FETCH_ASSOC ) ; if ( ! $ result ) { return [ ] ; } return $ result ; }
Get Rows from Table using a Prepared Statement
24,539
public function getJsonRows ( array $ arrWhat = [ '*' ] , array $ arrWhere = [ ] , array $ arrOrder = [ '`id` ASC' ] , array $ arrLimit = [ ] ) : string { $ rows = $ this -> loadByPrepStmt ( $ arrWhat , $ arrWhere , $ arrOrder , $ arrLimit ) ; $ json = json_encode ( $ rows , JSON_UNESCAPED_UNICODE ) ; return $ json ; }
Extension to LoadByPrepStmt this will return result as JSON instead of array
24,540
public function load ( int $ id ) { $ sql = "SELECT * FROM `" . $ this -> tableName . "` " . "WHERE `" . $ this -> primaryKey . "` = '" . $ id . "'" . "LIMIT 0,1;" ; $ stmt = $ this -> db -> query ( $ sql ) ; try { $ row = $ stmt -> fetch ( PDO :: FETCH_ASSOC ) ; } catch ( Exception $ ex ) { $ this -> log -> crit ( 'Could not find requested entry in mySQL: ' . $ sql . "\n" . $ ex -> getMessage ( ) ) ; } if ( ! is_array ( $ row ) ) { return ; } $ this -> loadWithData ( $ row ) ; }
Load specific entry from DB
24,541
public static function registerEnumTypes ( array $ types = [ ] ) { foreach ( $ types as $ name => $ callbacks ) { [ $ constructor , $ serializer ] = ( is_array ( $ callbacks ) ? $ callbacks : [ $ callbacks , null ] ) ; static :: registerEnumType ( $ name , $ constructor , $ serializer ) ; } }
Register a set of types with the provided constructor and serializer callables
24,542
public static function registerEnumType ( $ name , callable $ constructor , callable $ serializer = null ) { if ( static :: hasType ( $ name ) ) { return ; } $ serializer = $ serializer ?? function ( $ value ) { return ( $ value === null ) ? null : ( string ) $ value ; } ; static :: addType ( $ name , static :: class ) ; $ type = static :: getType ( $ name ) ; $ type -> name = $ name ; $ type -> constructor = $ constructor ; $ type -> serializer = $ serializer ; }
Registers an enumerable handler
24,543
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ formatter = $ this -> getHelper ( 'formatter' ) ; $ templates = $ this -> templateManager -> loadTemplates ( ) ; foreach ( $ templates as $ template ) { $ formattedLine = $ formatter -> formatSection ( 'OK' , 'Template "' . $ template [ 'bundle' ] . '" installed' ) ; $ output -> writeln ( $ formattedLine ) ; } }
This command loads all the templates installed
24,544
public function throwException ( $ message = '' , $ type = 'default' ) { switch ( $ type ) { case 'access-denied' : throw new AccessDeniedException ( $ message ) ; case 'not-found' : throw new NotFoundHttpException ( $ message ) ; case 'runtime' : throw new \ RuntimeException ( $ message ) ; default : throw new \ Exception ( $ message ) ; } }
Throw an Exception
24,545
protected function addNamedParameter ( $ name , $ value , $ queryBuilder , $ type = null ) { $ bound_suffix = '_' . ( microtime ( true ) * 10000 ) . '_' . random_int ( 1000 , 9999 ) . '_' . count ( $ queryBuilder -> getParameters ( ) ) ; $ placeHolder = ":" . $ name . $ bound_suffix ; $ queryBuilder -> setParameter ( substr ( $ placeHolder , 1 ) , $ value , $ type ) ; return $ placeHolder ; }
Add a new parameter to queryBuilder
24,546
protected function getResultFromQueryBuilder ( \ Doctrine \ ORM \ QueryBuilder $ queryBuilder ) { $ query = $ queryBuilder -> getQuery ( ) ; $ result = $ query -> getResult ( ) ; return $ result ; }
Get result from execution of queryBuilder
24,547
protected function getOneOrNullResultFromQueryBuilder ( QueryBuilder $ queryBuilder ) { $ query = $ queryBuilder -> getQuery ( ) ; $ result = $ query -> getOneOrNullResult ( ) ; return $ result ; }
Get one result from execution of queryBuilder
24,548
public function informationsAction ( Request $ request ) { if ( null !== $ redirect = $ this -> validateStep ( 'information' ) ) { return $ redirect ; } $ cart = $ this -> getCart ( ) ; $ user = $ this -> getUser ( ) ; if ( null !== $ user ) { $ cart -> setUser ( $ user ) -> setGender ( $ user -> getGender ( ) ) -> setFirstName ( $ user -> getFirstName ( ) ) -> setLastName ( $ user -> getLastName ( ) ) -> setEmail ( $ user -> getEmail ( ) ) ; } $ form = $ this -> createForm ( 'ekyna_cart_step_information' , $ cart ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ event = new OrderEvent ( $ cart ) ; $ this -> getDispatcher ( ) -> dispatch ( OrderEvents :: CONTENT_CHANGE , $ event ) ; if ( ! $ event -> isPropagationStopped ( ) ) { if ( $ cart -> requiresShipment ( ) ) { return $ this -> redirect ( $ this -> generateUrl ( 'ekyna_cart_shipment' ) ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'ekyna_cart_payment' ) ) ; } else { $ event -> toFlashes ( $ this -> getFlashBag ( ) ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'ekyna_cart_informations' ) ) ; } return $ this -> render ( 'EkynaCartBundle:Cart:informations.html.twig' , [ 'form' => $ form -> createView ( ) , 'cart' => $ cart , 'user' => $ user , ] ) ; }
Informations action .
24,549
public function shipmentAction ( Request $ request ) { if ( null !== $ redirect = $ this -> validateStep ( 'shipment' ) ) { return $ redirect ; } $ cart = $ this -> getCart ( ) ; if ( ! $ cart -> requiresShipment ( ) ) { return $ this -> redirect ( $ this -> generateUrl ( 'ekyna_cart_payment' ) ) ; } return $ this -> render ( 'EkynaCartBundle:Cart:shipment.html.twig' , [ ] ) ; }
Shipment action .
24,550
public function paymentAction ( Request $ request ) { if ( null !== $ redirect = $ this -> validateStep ( 'payment' ) ) { return $ redirect ; } $ cart = $ this -> getCart ( ) ; $ amount = $ this -> get ( 'ekyna_order.order.calculator' ) -> calculateOrderRemainingTotal ( $ cart ) ; $ paymentClass = $ this -> container -> getParameter ( 'ekyna_order.order_payment.class' ) ; $ payment = new $ paymentClass ; $ payment -> setAmount ( $ amount ) ; $ cart -> addPayment ( $ payment ) ; $ form = $ this -> createForm ( 'ekyna_cart_payment' , $ payment ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ event = new PaymentEvent ( $ payment ) ; $ this -> getDispatcher ( ) -> dispatch ( PaymentEvents :: PREPARE , $ event ) ; if ( $ event -> isPropagationStopped ( ) ) { $ event -> toFlashes ( $ this -> getFlashBag ( ) ) ; } elseif ( null !== $ response = $ event -> getResponse ( ) ) { return $ response ; } } return $ this -> render ( 'EkynaCartBundle:Cart:payment.html.twig' , [ 'cart' => $ cart , 'form' => $ form -> createView ( ) , ] ) ; }
Payment action .
24,551
public function confirmationAction ( Request $ request ) { $ order = $ this -> get ( 'ekyna_order.order.repository' ) -> findOneByKey ( $ request -> attributes -> get ( 'orderKey' ) ) ; if ( null === $ order ) { throw new NotFoundHttpException ( 'Order not found.' ) ; } if ( null !== $ user = $ order -> getUser ( ) ) { if ( $ user !== $ this -> getUser ( ) ) { throw new AccessDeniedHttpException ( 'You are not allowed to view this resource.' ) ; } } if ( null === $ payment = $ order -> findPaymentById ( $ request -> attributes -> get ( 'paymentId' ) ) ) { throw new NotFoundHttpException ( 'Payment not found.' ) ; } $ method = $ payment -> getMethod ( ) ; $ message = $ method -> getMessageByState ( $ payment -> getState ( ) ) ; if ( null === $ message || 0 == strlen ( $ message -> getFlash ( ) ) ) { $ message = null ; } return $ this -> render ( 'EkynaCartBundle:Cart:confirmation.html.twig' , [ 'order' => $ order , 'payment' => $ payment , 'message' => $ message , ] ) ; }
Confirmation action .
24,552
public function resetAction ( Request $ request ) { $ cart = $ this -> getCart ( ) ; $ event = new OrderEvent ( $ cart ) ; $ this -> get ( 'ekyna_order.order.operator' ) -> delete ( $ event , true ) ; if ( ! $ event -> hasErrors ( ) ) { $ this -> addFlash ( 'ekyna_cart.message.reset' ) ; } else { $ event -> toFlashes ( $ this -> getFlashBag ( ) ) ; } return $ this -> redirectAfterContentChange ( $ request ) ; }
Reset action .
24,553
public function removeItemAction ( Request $ request ) { $ cart = $ this -> getCart ( ) ; $ item = $ this -> getDoctrine ( ) -> getRepository ( 'EkynaOrderBundle:OrderItem' ) -> findOneBy ( [ 'id' => $ request -> attributes -> get ( 'itemId' ) , 'orderId' => $ cart -> getId ( ) , ] ) ; if ( null === $ item ) { throw new NotFoundHttpException ( $ this -> getTranslator ( ) -> trans ( 'ekyna_cart.message.item_not_found' ) ) ; } $ event = new OrderItemEvent ( $ cart , $ item ) ; $ this -> getDispatcher ( ) -> dispatch ( OrderItemEvents :: REMOVE , $ event ) ; if ( ! $ event -> isPropagationStopped ( ) ) { $ message = 'ekyna_cart.message.item_remove.success' ; $ type = 'success' ; } else { $ message = 'ekyna_cart.message.item_remove.failure' ; $ type = 'danger' ; } $ this -> addFlash ( $ this -> getTranslator ( ) -> trans ( $ message , [ '{{ name }}' => $ item -> getDesignation ( ) , '{{ path }}' => $ this -> generateUrl ( 'ekyna_cart_index' ) , ] ) , $ type ) ; if ( $ request -> isXmlHttpRequest ( ) ) { return new Response ( ) ; } return $ this -> redirectAfterContentChange ( $ request ) ; }
Remove item action .
24,554
protected function validateStep ( $ step ) { $ stepGroups = [ 'information' => [ 'ekyna_cart_index' , [ 'Default' , 'Cart' ] ] , 'shipment' => [ 'ekyna_cart_informations' , [ 'Default' , 'Cart' , 'Information' ] ] , 'payment' => [ 'ekyna_cart_shipment' , [ 'Default' , 'Cart' , 'Information' , 'Shipment' ] ] , ] ; if ( ! array_key_exists ( $ step , $ stepGroups ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Undefined step "%s".' , $ step ) ) ; } $ cart = $ this -> getCart ( ) ; $ errorList = $ this -> get ( 'validator' ) -> validate ( $ cart , $ stepGroups [ $ step ] [ 1 ] ) ; if ( 0 != $ errorList -> count ( ) ) { return $ this -> redirect ( $ this -> generateUrl ( $ stepGroups [ $ step ] [ 0 ] ) ) ; } return null ; }
Validates the cart for the given step name .
24,555
protected function securityCheck ( Request $ request ) { if ( ! $ this -> get ( 'security.authorization_checker' ) -> isGranted ( 'IS_AUTHENTICATED_REMEMBERED' ) ) { $ request -> getSession ( ) -> set ( '_ekyna.login_success.target_path' , 'ekyna_cart_informations' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'fos_user_security_login' ) ) ; } return null ; }
Check that user is logged .
24,556
protected function redirectAfterContentChange ( Request $ request ) { if ( null !== $ referer = $ request -> headers -> get ( 'referer' , null ) ) { return $ this -> redirect ( $ referer ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'ekyna_cart_index' ) ) ; }
Redirects after order content changed .
24,557
public function find ( $ oEntityCriteria ) { $ this -> _checkEntity ( $ oEntityCriteria ) ; $ aEntity = get_object_vars ( LibEntity :: getRealEntity ( $ oEntityCriteria ) ) ; $ sPrimaryKeyName = LibEntity :: getPrimaryKeyName ( $ oEntityCriteria ) ; $ aResults = $ this -> orm -> select ( array ( '*' ) ) -> from ( $ this -> _sTableName ) -> where ( array ( $ sPrimaryKeyName => $ aEntity [ $ sPrimaryKeyName ] ) ) -> load ( ) ; if ( $ aResults ) { return $ aResults [ 0 ] ; } if ( $ this -> _isFilter ( ) ) { foreach ( $ aResults as $ iKey => $ oValue ) { $ aResults [ $ iKey ] = $ this -> _applyFilter ( $ oValue ) ; } } return $ aResults ; }
classic method to find an entity
24,558
public function findOneBy ( array $ aArguments ) { $ sEntityNamespace = preg_replace ( '/^(.*)Model\\\\.+$/' , '$1Entity\\' , get_called_class ( ) ) ; $ aResults = $ this -> orm -> select ( array ( '*' ) ) -> from ( $ this -> _sTableName ) -> where ( $ aArguments ) -> limit ( 1 ) -> load ( false , $ sEntityNamespace ) ; if ( isset ( $ aResults [ 0 ] ) && $ this -> _isFilter ( ) ) { $ aResults [ 0 ] = $ this -> _applyFilter ( $ aResults [ 0 ] ) ; } if ( isset ( $ aResults [ 0 ] ) ) { return $ aResults [ 0 ] ; } else { return false ; } }
return an entity that it is found with the arguments
24,559
public function findOrderBy ( array $ aArguments ) { $ sEntityNamespace = preg_replace ( '/^(.*)Model\\\\.+$/' , '$1Entity\\' , get_called_class ( ) ) ; $ aResults = $ this -> orm -> select ( array ( '*' ) ) -> from ( $ this -> _sTableName ) -> orderBy ( $ aArguments ) -> load ( false , $ sEntityNamespace ) ; if ( $ this -> _isFilter ( ) ) { foreach ( $ aResults as $ iKey => $ oValue ) { $ aResults [ $ iKey ] = $ this -> _applyFilter ( $ oValue ) ; } } return $ aResults ; }
return list of entities that they are found with the arguments
24,560
public function getLastRow ( ) { $ sEntityNamespace = preg_replace ( '/^(.*)Model\\\\.+$/' , '$1Entity\\' , get_called_class ( ) ) ; $ aResults = $ this -> orm -> select ( array ( '*' ) ) -> from ( $ this -> _sTableName ) -> orderBy ( array ( LibEntity :: getPrimaryKeyName ( $ this -> entity ) => 'DESC' ) ) -> limit ( 1 ) -> load ( false , $ sEntityNamespace ) ; if ( isset ( $ aResults [ 0 ] ) && $ this -> _isFilter ( ) ) { $ aResults [ 0 ] = $ this -> _applyFilter ( $ aResults [ 0 ] ) ; } return $ aResults [ 0 ] ; }
get last row
24,561
public function insertAndGet ( $ oEntity ) { $ iResult = $ this -> insert ( $ oEntity ) ; if ( $ iResult ) { return $ this -> getLastRow ( ) ; } return $ iResult ; }
save Entity and get it
24,562
public function updateAndGet ( $ oEntity ) { $ sEntityNamespace = preg_replace ( '/^(.*)Model\\\\.+$/' , '$1Entity\\' , get_called_class ( ) ) ; $ mResult = $ this -> update ( $ oEntity ) ; if ( $ result ) { $ aEntity = get_object_vars ( LibEntity :: getRealEntity ( $ oEntity ) ) ; $ mPrimaryKey = LibEntity :: getPrimaryKeyName ( $ aEntity ) ; $ mResult = $ this -> orm -> select ( array ( '*' ) ) -> from ( $ this -> _sTableName ) -> where ( array ( $ mPrimaryKey => $ aEntity [ $ mPrimaryKey ] ) ) -> load ( false , $ sEntityNamespace ) ; if ( $ this -> _isFilter ( ) ) { foreach ( $ mResult as $ iKey => $ oValue ) { $ mResult [ $ iKey ] = $ this -> _applyFilter ( $ oValue ) ; } } } return $ mResult ; }
update Entity and get it
24,563
public function delete ( $ oEntityCriteria ) { $ this -> _checkEntity ( $ oEntityCriteria ) ; $ aEntity = LibEntity :: getAllEntity ( $ oEntityCriteria , true ) ; $ this -> orm -> delete ( $ this -> _sTableName ) -> where ( $ aEntity ) -> save ( ) ; return $ this ; }
classic method to delete one entities
24,564
public function truncate ( ) { $ aClass = explode ( '\\' , get_called_class ( ) ) ; $ sClassName = $ aClass [ count ( $ aClass ) - 1 ] ; $ this -> orm -> truncate ( $ sClassName ) -> save ( ) ; return $ this ; }
classic method to truncate a table
24,565
private function _checkEntity ( $ oEntityCriteria ) { $ sClassName = get_called_class ( ) ; $ sClassName = str_replace ( 'Model' , 'Entity' , $ sClassName ) ; if ( ! is_object ( $ oEntityCriteria ) || ! $ oEntityCriteria instanceof $ sClassName ) { throw new \ Exception ( 'You must passed ' . $ sClassName . ' like Entity!' ) ; } }
check if the entity passed is good
24,566
private function _applyFilter ( $ oResult ) { $ oResult = $ this -> _cFilterCallback ( $ oResult ) ; foreach ( $ this -> _aHasOne as $ sKey => $ aParam ) { $ oResult -> hasOne ( $ aParam [ 0 ] , $ aParam [ 1 ] , $ aParam [ 2 ] , $ aParam [ 3 ] , $ aParam [ 4 ] ) ; } foreach ( $ this -> _aHasMany as $ sKey => $ aParam ) { $ oResult -> hasMany ( $ aParam [ 0 ] , $ aParam [ 1 ] , $ aParam [ 2 ] , $ aParam [ 3 ] , $ aParam [ 4 ] ) ; } return $ this -> _cFilterCallback ( $ oResults ) ; }
apply the filter on the result and add the join
24,567
public function belongsTo ( $ sPrimaryKeyName , $ sEntityJoinName , $ sForeignKeyName , $ sNamespaceEntity , array $ aOptions = array ( ) ) { $ this -> _aHasOne [ $ sEntityJoinName ] = array ( $ sPrimaryKeyName , $ sEntityJoinName , $ sForeignKeyName , $ sNamespaceEntity ) ; }
create a join in many to one
24,568
public function hasManyToMany ( $ sPrimaryKeyName , $ sEntityJoinName , $ sForeignKeyName , $ sNamespaceEntity , $ sManyToManyKeyName , $ sManyToManyTableName , array $ aOptions = array ( ) ) { $ this -> _ahasMany [ $ sEntityJoinName ] = function ( $ mParameters = null ) use ( $ sPrimaryKeyName , $ sEntityJoinName , $ sForeignKeyName , $ sManyToManyKeyName , $ sManyToManyTableName , $ sNamespaceEntity ) { if ( ! isset ( $ this -> $ sEntityJoinName ) ) { $ oOrm = new Orm ; $ oOrm -> select ( array ( '*' ) ) -> from ( $ sEntityJoinName ) ; if ( $ mParameters ) { $ aWhere [ $ sForeignKeyName ] = $ mParameters ; } else { $ sMethodName = 'get_' . $ sPrimaryKeyName ; $ aWhere [ $ sForeignKeyName ] = $ this -> $ sMethodName ( ) ; } $ this -> $ sEntityJoinName = $ oOrm -> where ( $ aWhere ) -> load ( false , $ sNamespaceEntity . '\\' ) ; } $ aResults = array ( ) ; foreach ( $ this -> $ sEntityJoinName as $ iKey => $ oOne ) { $ oOrm = new Orm ; $ oOrm -> select ( array ( '*' ) ) -> from ( $ sManyToManyTableName ) ; if ( $ mParameters ) { $ aWhere [ $ sManyToManyKeyName ] = $ mParameters ; } else { $ sMethodName = 'get_' . $ sManyToManyKeyName ; $ aWhere [ $ sManyToManyKeyName ] = $ this -> $ sMethodName ( ) ; } $ aResults [ ] = $ oOrm -> where ( $ aWhere ) -> load ( false , $ sNamespaceEntity . '\\' ) ; } return $ aResults ; } ; }
create a join in many to many
24,569
public function addRule ( $ id , array $ rule , $ initial = false ) { if ( isset ( $ this -> rules [ $ id ] ) ) { throw new \ Exception ( 'Rule is already defined!' ) ; } $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveArrayIterator ( $ rule ) , true ) ; foreach ( $ iterator as $ k => $ v ) { if ( ! is_int ( $ k ) ) { if ( ! is_array ( $ v ) ) { throw new \ Exception ( sprintf ( "No array specified for rule operator '%s'" , $ k ) ) ; } switch ( $ k ) { case '$option' : if ( ( $ cnt = count ( $ v ) ) != 1 ) { throw new \ Exception ( sprintf ( "Rule operator '\$option' takes exactly one item, '%d' given" , $ cnt ) ) ; } break ; case '$alternation' : case '$concatenation' : case '$repeat' : break ; default : throw new \ Exception ( sprintf ( "Invalid rule operator '%s'" , $ k ) ) ; } } } $ this -> rules [ $ id ] = $ rule ; if ( $ initial ) { $ this -> initial = $ id ; } }
Add a rule to the grammar .
24,570
public function addEvent ( $ id , callable $ cb ) { if ( ! isset ( $ this -> events [ $ id ] ) ) { $ this -> events [ $ id ] = [ ] ; } $ this -> events [ $ id ] [ ] = $ cb ; }
Add an event for a token .
24,571
public function getEBNF ( ) { $ glue = array ( '$concatenation' => array ( '' , ' , ' , '' ) , '$alternation' => array ( '( ' , ' | ' , ' )' ) , '$repeat' => array ( '{ ' , '' , ' }' ) , '$option' => array ( '[ ' , '' , ' ]' ) ) ; $ render = function ( $ rule ) use ( $ glue , & $ render ) { if ( is_array ( $ rule ) ) { $ type = key ( $ rule ) ; foreach ( $ rule [ $ type ] as & $ _rule ) { $ _rule = $ render ( $ _rule ) ; } $ return = $ glue [ $ type ] [ 0 ] . implode ( $ glue [ $ type ] [ 1 ] , $ rule [ $ type ] ) . $ glue [ $ type ] [ 2 ] ; } else { $ return = $ rule ; } return $ return ; } ; $ return = '' ; foreach ( $ this -> rules as $ name => $ rule ) { $ return .= $ name . ' = ' . $ render ( $ rule ) . " ;\n" ; } return $ return ; }
Return the EBNF for the defined grammar .
24,572
public function doExecute ( Console $ console ) { if ( file_exists ( $ this -> targetFile ) ) { $ console -> out -> writeLine ( 'Already exists' ) ; return ; } $ creator = new Creator ( ) ; $ creator -> createStub ( $ this -> baseClass , $ this -> targetFile ) ; $ console -> out -> writeLine ( 'Created user configuration in ' . $ this -> targetFile ) ; }
Creates a user configuration class to overwrite a default configuration
24,573
static public function getInstance ( $ instanceName ) { if ( ! isset ( self :: $ instanceArray [ $ instanceName ] ) ) { self :: $ instanceArray [ $ instanceName ] = new MDatabaseConnection ( ) ; } return self :: $ instanceArray [ $ instanceName ] ; }
multiton to administrate the instances of the connection and global accessing
24,574
public function connect ( ) { $ this -> connection = @ new \ mysqli ( $ this -> host , $ this -> username , $ this -> password , $ this -> databaseName ) ; if ( ! $ this -> connection -> connect_errno ) { $ this -> connection -> autocommit ( 1 ) ; return true ; } else { return false ; } }
connects to the database server
24,575
public function query ( $ sqlCommand ) { $ result = $ this -> connection -> query ( $ sqlCommand ) ; if ( $ this -> getError ( ) != null ) { throw new MWebfilesFrameworkException ( "Error orrured on executing sql: " . $ this -> getError ( ) . ", SQL: " . $ sqlCommand ) ; } return $ result ; }
queries the database with the specified sql command
24,576
public function Initialize ( ) { if ( $ this -> DeliveryType ( ) == DELIVERY_TYPE_ALL ) $ this -> Head = new HeadModule ( $ this ) ; parent :: Initialize ( ) ; }
This is a good place to include JS CSS and modules used by all methods of this controller .
24,577
public function offsetGet ( $ offset ) { if ( ! isset ( $ this -> container [ $ offset ] ) ) { $ this -> container [ $ offset ] = new self ( ) ; } return $ this -> container [ $ offset ] ; }
Get value from array .
24,578
protected function InitForm ( ) { $ this -> select = $ this -> LoadElement ( ) ; $ this -> AddNameField ( ) ; $ this -> AddValueField ( ) ; $ this -> AddLabelField ( ) ; $ this -> AddOptionsField ( ) ; $ this -> AddDisableFrontendValidationField ( ) ; $ this -> AddRequiredField ( ) ; $ this -> AddTemplateField ( ) ; $ this -> AddCssClassField ( ) ; $ this -> AddCssIDField ( ) ; $ this -> AddSubmit ( ) ; }
Initializes the form by adding all necessary elements
24,579
protected function SaveElement ( ) { $ this -> select -> SetLabel ( $ this -> Value ( 'Label' ) ) ; $ this -> select -> SetName ( $ this -> Value ( 'Name' ) ) ; $ this -> select -> SetValue ( $ this -> Value ( 'Value' ) ) ; $ this -> select -> SetDisableFrontendValidation ( ( bool ) $ this -> Value ( 'DisableFrontendValidation' ) ) ; $ this -> select -> SetRequired ( ( bool ) $ this -> Value ( 'Required' ) ) ; return $ this -> select ; }
Stores the select content s base properties
24,580
public function hyperlink ( $ label , $ url , $ options = array ( ) ) { $ defaults = array ( 'class' => 'btn btn-info' ) ; $ options = array_merge ( $ defaults , $ options ) ; return parent :: hyperlink ( $ label , $ url , $ options ) ; }
Returns a Bootstrap flavoured hypelink
24,581
protected function findRelativePathView ( $ name ) { $ caller = Backtrace :: getViewOrigin ( ) ; return $ this -> findInPaths ( $ name , [ dirname ( $ caller ) ] ) ; }
Get the path to a template with a relative path .
24,582
public function innerJoin ( $ table , $ alias_or_cond , $ cond = null ) { if ( is_null ( $ cond ) ) $ this -> joins [ ] = new JoinClause ( JoinClause :: INNER_JOIN , $ table , null , $ alias_or_cond ) ; else $ this -> joins [ ] = new JoinClause ( JoinClause :: INNER_JOIN , $ table , $ alias_or_cond , $ cond ) ; return $ this ; }
Appends an inner join to join list
24,583
public function leftJoin ( $ table , $ alias_or_cond , $ cond = null ) { if ( is_null ( $ cond ) ) $ this -> joins [ ] = new JoinClause ( JoinClause :: LEFT_JOIN , $ table , null , $ alias_or_cond ) ; else $ this -> joins [ ] = new JoinClause ( JoinClause :: LEFT_JOIN , $ table , $ alias_or_cond , $ cond ) ; return $ this ; }
Appends a left join to join list
24,584
public function fullOuterJoin ( $ table , $ alias_or_cond , $ cond = null ) { if ( is_null ( $ cond ) ) $ this -> joins [ ] = new JoinClause ( JoinClause :: FULL_OUTER_JOIN , $ table , null , $ alias_or_cond ) ; else $ this -> joins [ ] = new JoinClause ( JoinClause :: FULL_OUTER_JOIN , $ table , $ alias_or_cond , $ cond ) ; return $ this ; }
Appends a full outer join to join list
24,585
protected function updateSchema ( Schema $ schema ) { foreach ( $ schema -> getJoins ( ) as $ join ) { $ assoc = $ join -> getAssociation ( ) ; $ parent = $ join -> getParent ( ) ; if ( is_null ( $ parent ) ) $ assoc -> appendJoin ( $ this , $ this -> alias , $ join -> getAlias ( ) , true ) ; else { $ alias = $ schema -> getJoin ( $ parent ) -> getAlias ( ) ; $ assoc -> appendJoin ( $ this , $ alias , $ join -> getAlias ( ) , true ) ; } } }
Updates query schema
24,586
public function exec ( ) { list ( $ query , $ args ) = $ this -> build ( ) ; if ( empty ( $ this -> config ) ) return call_user_func ( [ $ this -> fluent -> getMapper ( ) , 'sql' ] , $ query , $ args ) ; return call_user_func ( [ $ this -> fluent -> getMapper ( ) -> merge ( $ this -> config ) , 'sql' ] , $ query , $ args ) ; }
Executes the resulting query against current database
24,587
public function get ( $ name ) { $ names = explode ( self :: SEPARATOR , $ name ) ; $ method = array_pop ( $ names ) ; if ( $ names ) { $ class_name = 'Task\\' . join ( '\\' , array_map ( 'ucfirst' , $ names ) ) . 'TaskList' ; } else { $ class_name = 'Task\\TaskList' ; } $ class_path = $ this -> loader -> getPathByClass ( $ class_name , false ) ; if ( $ class_path === null || ! $ class_path -> isExists ( ) ) throw new NotFoundException ( "No such task. -> {$name}" ) ; require_once $ class_path ; $ class_name = $ class_path -> getClassName ( ) ; $ taskList = new $ class_name ( ) ; $ taskList -> setOutput ( $ this -> output ) ; $ taskList -> setContainer ( $ this -> raikiri ( ) ) ; if ( ! $ taskList -> has ( $ method ) ) throw new NotImplementsException ( "No such task. -> {$name}" ) ; return $ taskList -> get ( $ method ) ; }
get task .
24,588
public function find ( $ name = null ) { $ tasks = [ ] ; foreach ( $ this -> application -> getAppPaths ( ) as $ path ) { $ files = $ this -> finder -> path ( $ path [ 'dir' ] . DS . 'Task' ) -> recursive ( ) -> name ( '*TaskList.php' ) -> find ( ) ; foreach ( $ files as $ file ) { $ task_path = substr ( $ file , strlen ( $ path [ 'dir' ] . DS . 'Task' . DS ) , - strlen ( 'TaskList.php' ) ) ; $ task_name = join ( ':' , array_map ( 'lcfirst' , explode ( DS , $ task_path ) ) ) ; $ class_name = $ file -> getClassName ( ) ; if ( ! class_exists ( $ class_name ) ) continue ; $ refletion = new ReflectionClass ( $ class_name ) ; if ( ! $ refletion -> isInstantiable ( ) ) continue ; $ taskList = $ refletion -> newInstance ( ) ; $ taskList -> setName ( $ task_name ) ; foreach ( $ taskList -> getTasks ( ) as $ task ) { $ tasks [ ] = $ task ; } } } if ( $ name ) { $ tasks = array_filter ( $ tasks , function ( $ task ) use ( $ name ) { return strpos ( $ task -> getName ( ) , $ name ) === 0 ; } ) ; } return $ tasks ; }
find task .
24,589
public function execute ( $ name , $ option = [ ] ) { if ( is_string ( $ name ) ) { $ names = explode ( self :: SEPARATOR , $ name ) ; $ method = array_pop ( $ names ) ; $ task = $ this -> get ( $ name ) ; } $ task -> execute ( $ option ) ; }
call task .
24,590
private function supportData ( ) { $ dataClass = $ this -> type -> getDataClass ( ) ; return $ this -> data instanceof $ dataClass || $ dataClass === get_class ( $ this -> data ) ; }
Check if mapper type support data .
24,591
public function cast ( $ object ) { if ( ! is_object ( $ object ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Expected an object, but got %s!' , gettype ( $ object ) ) ) ; } foreach ( $ this -> map as $ name => $ type ) { if ( isset ( $ object -> { $ name } ) ) { try { $ object -> { $ name } = $ type -> cast ( $ object -> { $ name } ) ; } catch ( \ InvalidArgumentException $ iaex ) { throw new \ InvalidArgumentException ( sprintf ( 'Unexpected value for property %s: %s' , $ name , $ iaex -> getMessage ( ) ) , 0 , $ iaex ) ; } } } return $ object ; }
Cast the public values of the given object to the typecast information defined in this class .
24,592
public function renderCategoryTree ( \ Twig_Environment $ environment , $ tree , $ selectedCategory = null , $ currentCategory = null , $ template = null ) { if ( count ( $ tree ) ) { if ( $ template === null ) { $ template = $ this -> getTemplate ( ) ; } return $ environment -> render ( $ template , [ 'categories' => $ tree , 'selected_category' => $ selectedCategory , 'current_category' => $ currentCategory , ] ) ; } return null ; }
Renders category tree .
24,593
protected function setupConnectionFactory ( ConnectionResolverInterface $ connectionResolver ) { Model :: setConnectionResolver ( $ connectionResolver ) ; $ this -> connectionFactory = new ConnectionFactory ( $ connectionResolver ) ; }
Build the connection factory instance .
24,594
public function isSingleton ( $ type ) : bool { assert ( isset ( $ this -> types [ $ type ] ) ) ; return $ this -> types [ $ type ] ; }
Only DI \ Provider can call this function . So DI \ Provider is responsible to the assertion .
24,595
public function Content ( ) { $ content = $ this -> owner -> Content ; $ matches = array ( ) ; preg_match_all ( '/<a.*href="\[file_link,id=([0-9]+)\].*".*>.*<\/a>/U' , $ content , $ matches ) ; for ( $ i = 0 ; $ i < count ( $ matches [ 0 ] ) ; $ i ++ ) { $ file = DataObject :: get_by_id ( 'File' , $ matches [ 1 ] [ $ i ] ) ; if ( $ file ) { $ size = $ file -> getSize ( ) ; $ ext = strtoupper ( $ file -> getExtension ( ) ) ; $ newLink = $ matches [ 0 ] [ $ i ] . "<span class='fileExt'> [$ext, $size]</span>" ; $ content = str_replace ( $ matches [ 0 ] [ $ i ] , $ newLink , $ content ) ; } } $ pattern = '/<a href=\"(h[^\"]*)\">(.*)<\/a>/iU' ; $ replacement = '<a href="$1" class="external">$2</a>' ; $ result = preg_replace ( $ pattern , $ replacement , $ content , - 1 ) ; return $ result ; }
Give external links the external class and affix size and type prefixes to files .
24,596
public function results ( $ data , $ form , $ request ) { $ result = null ; $ results = $ form -> getResults ( ) ; $ query = $ form -> getSearchQuery ( ) ; foreach ( $ results as $ result ) { $ contextualTitle = new Text ( ) ; $ contextualTitle -> setValue ( $ result -> MenuTitle ? $ result -> MenuTitle : $ result -> Title ) ; $ result -> ContextualTitle = $ contextualTitle -> ContextSummary ( 300 , $ query ) ; if ( ! $ result -> Content && $ result -> ClassName == 'File' ) { $ result -> ContextualContent = "A file named \"$result->Name\" ($result->Size)." ; } else { $ valueField = $ result -> obj ( 'Content' ) ; $ valueField -> setValue ( ShortcodeParser :: get_active ( ) -> parse ( $ valueField -> getValue ( ) ) ) ; $ result -> ContextualContent = $ valueField -> ContextSummary ( 300 , $ query ) ; } } $ rssLink = HTTP :: setGetVar ( 'rss' , '1' ) ; $ context = array ( 'Results' => $ results , 'Query' => $ query , 'Title' => _t ( 'SearchForm.SearchResults' , 'Search Results' ) , 'RSSLink' => $ rssLink ) ; if ( ! $ this -> owner -> request -> getVar ( 'rss' ) ) { RSSFeed :: linkToFeed ( $ rssLink , "Search results for query \"$query\"." ) ; $ result = $ this -> owner -> customise ( $ context ) -> renderWith ( array ( 'Page_results' , 'Page' ) ) ; } else { $ fullList = $ results -> getList ( ) -> sort ( 'LastEdited' , 'DESC' ) ; $ siteName = SiteConfig :: current_site_config ( ) -> Title ; $ siteTagline = SiteConfig :: current_site_config ( ) -> Tagline ; if ( $ siteName ) { $ title = "$siteName search results for query \"$query\"." ; } else { $ title = "Search results for query \"$query\"." ; } $ rss = new RSSFeed ( $ fullList , $ this -> owner -> request -> getURL ( ) , $ title , $ siteTagline , "Title" , "ContextualContent" , null ) ; $ rss -> setTemplate ( 'Page_results_rss' ) ; $ result = $ rss -> outputToBrowser ( ) ; } return $ result ; }
Overrides the ContentControllerSearchExtension and adds snippets to results .
24,597
public function render ( $ options = array ( ) ) { $ string = $ options [ 'string' ] ; $ data = $ options [ 'data' ] ; return $ this -> renderTpl ( $ string , $ data ) ; }
Render a string .
24,598
public function setTargetDirectory ( $ dir ) { if ( ! is_string ( $ dir ) || empty ( $ dir ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid target directory provided; must be a non-empty ' . 'string, "%s" received.' , is_object ( $ dir ) ? get_class ( $ dir ) : gettype ( $ dir ) ) ) ; } $ this -> targetDirectory = $ dir ; }
Sets the target directory to move .
24,599
public function setFilePermissions ( $ permissions ) { if ( ! is_int ( $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid file permissins provided; must be an ' . 'integer, "%s" received.' , is_object ( $ permissions ) ? get_class ( $ permissions ) : gettype ( $ permissions ) ) ) ; } if ( ! ( 0b100000000 & $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid file permissions "%s" provided. ' . 'Files will not available for reading.' , decoct ( $ permissions ) ) ) ; } if ( ! ( 0b010000000 & $ permissions ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid file permissions "%s" provided. ' . 'Files will not available for writing.' , decoct ( $ permissions ) ) ) ; } if ( 0b001000000 & $ permissions ) { throw new InvalidArgumentException ( sprintf ( 'Invalid file permissions "%s" provided. ' . 'Files will be executable.' , decoct ( $ permissions ) ) ) ; } $ this -> filePermissions = $ permissions ; }
Sets the file permissions .