idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
14,300
protected function handleBackendOptions ( Descriptor $ descriptor , array $ options ) { if ( isset ( $ options [ 'host' ] ) ) { $ host = $ options [ 'host' ] ; if ( isset ( $ options [ 'port' ] ) ) { $ host .= ':' . $ options [ 'port' ] ; } $ descriptor -> host = $ host ; } if ( isset ( $ options [ 'persistent' ] ) ) {...
Handle the Phalcon backend options
14,301
public static function checkNeeded ( ) : void { set_time_limit ( 0 ) ; ignore_user_abort ( true ) ; ini_set ( 'memory_limit' , '1G' ) ; $ services_collection = new ServiceEntityRepository ; $ services_collection -> setWhereRunning ( 0 ) -> setWhereAutoStart ( 1 ) ; foreach ( $ services_collection -> getAsArrayOfObjects...
Check if any of background service needs to be run
14,302
public static function run ( $ id ) : bool { $ id = abs ( ( int ) $ id ) ; $ service_entity = ServiceEntityRepository :: findOneEntityById ( $ id ) ; if ( ! $ service_entity || $ service_entity -> getRunning ( ) ) { return false ; } $ file = Finder :: getInstance ( ) -> searchForRealPath ( $ service_entity -> getFile (...
Run service once
14,303
public function get_by_name ( $ name ) { $ filtered = $ this -> filter ( function ( $ c ) use ( $ name ) { return $ c instanceof ValueComponentInterface && $ c -> name === $ name ; } ) ; if ( count ( $ filtered ) < 1 ) { throw new \ RuntimeException ( "No component with the name <b>$name</b> could be found." ) ; } retu...
Get a component by name . Only applicable to value components .
14,304
public function add_component ( array $ args ) { if ( ! array_key_exists ( 'type' , $ args ) ) { throw new \ RuntimeException ( "Component configuration arrays must have a <b>type</b> argument" ) ; } $ comp = ComponentFactory :: create ( $ args [ 'type' ] , $ args ) ; $ this -> verify_name_uniqueness ( $ comp ) ; $ thi...
Add a single component to the list
14,305
private function verify_name_uniqueness ( AbstractComponent $ comp ) { if ( ! ( $ comp instanceof ValueComponentInterface ) ) { return ; } foreach ( $ this -> components as $ c ) { if ( $ c -> name === $ comp -> name ) { throw new \ RuntimeException ( "Duplicate component name detected for the name <b>{$c->name}</b>." ...
Verify that the given component name is unique among the list of value components
14,306
public function getIniPrefix ( $ accountId = null ) { if ( $ accountId == null ) { $ arr = array ( ) ; foreach ( $ this -> configs as $ key => $ value ) { $ pos = strpos ( $ key , '.' ) ; if ( strstr ( $ key , "acct" ) ) { $ arr [ ] = substr ( $ key , 0 , $ pos ) ; } } return array_unique ( $ arr ) ; } else { $ iniPref...
Utility method for handling account configuration return config key corresponding to the API accountId passed in
14,307
public function updateLogin ( $ type = null ) { $ this -> authenticated_as = $ type ; $ this -> authenticated_at = setTime ( 'now' ) ; $ this -> failed_login_attempts = 0 ; $ this -> save ( ) ; }
Track the log in details for this user .
14,308
public static function failedLogin ( $ email ) { $ user = self :: where ( 'email' , $ email ) -> first ( ) ; if ( ! is_null ( $ user ) ) { $ user -> increment ( 'failed_login_attempts' ) ; } $ rules = config ( 'jumpgate.users.blocking' , null ) ; if ( is_null ( $ rules ) ) { return true ; } supportCollector ( $ rules )...
When a log in fails increment the failed count .
14,309
private function getUplineId ( $ custId ) { $ entity = $ this -> daoDwnl -> getById ( $ custId ) ; $ result = $ entity -> getParentRef ( ) ; return $ result ; }
Get upline ID for current customer .
14,310
private function registerBonus ( $ saleId , $ custId , $ amount , $ fee , $ state ) { $ entity = new ERegistry ( ) ; $ entity -> setSaleRef ( $ saleId ) ; $ entity -> setUplineRef ( $ custId ) ; $ entity -> setAmountTotal ( $ amount ) ; $ entity -> setAmountFee ( $ fee ) ; $ entity -> setState ( $ state ) ; $ this -> d...
Save new bonus entry in DB .
14,311
public function setDefaultHost ( $ host , $ port = null ) { $ this -> defaultHost = ( string ) $ host ; if ( $ port !== null ) { $ this -> setDefaultPort ( $ port ) ; } return $ this ; }
Set default host for each server
14,312
public function setHosts ( $ hosts ) { $ this -> hosts = [ ] ; if ( ! $ hosts instanceof Traversable && ! is_array ( $ hosts ) ) { throw new Exceptions \ OptionsError ( 'Hosts data must be an array or a traversable' ) ; } foreach ( $ hosts as $ name => $ host ) { if ( is_int ( $ name ) ) { $ this -> addHost ( $ host ) ...
Set the hosts of the connection pool
14,313
public function addHost ( $ host , $ name = null ) { $ host = $ this -> normalizeHost ( $ host ) ; if ( $ host -> hasUsername ( ) ) { $ this -> setUsername ( $ host -> getUsername ( ) ) ; $ host -> removeUsername ( ) ; if ( $ host -> hasPassword ( ) ) { $ this -> setPassword ( $ host -> getPassword ( ) ) ; $ host -> re...
Add the host to the connection pool
14,314
public function getDatabases ( ) { $ client = $ this -> getClient ( ) ; if ( $ this -> _profilerEnabled ) { $ event = $ this -> getProfiler ( ) -> startRead ( 'Databases list' ) ; } $ databasesRaw = $ client -> listDBs ( ) ; if ( $ this -> _profilerEnabled ) { $ event -> stopSuccess ( ) ; } $ databases = [ ] ; foreach ...
Get a databases list
14,315
public function getCollections ( $ databaseName = null ) { $ database = $ this -> getDatabase ( $ databaseName ) ; if ( $ this -> _profilerEnabled ) { $ event = $ this -> getProfiler ( ) -> startRead ( 'Collections list' ) ; } $ collections = $ database -> getCollectionNames ( ) ; if ( $ this -> _profilerEnabled ) { $ ...
Get a collections list of a database
14,316
public function insert ( $ collectionName , array $ data , array $ options = [ ] ) { $ collection = $ this -> getCollection ( $ collectionName ) ; if ( $ this -> _profilerEnabled ) { $ message = 'db.' . $ collectionName . '.insert(' . json_encode ( $ data ) . ');' ; $ event = $ this -> getProfiler ( ) -> startInsert ( ...
Insert the data into the collection
14,317
public function find ( $ collectionName , array $ criteria = [ ] , array $ fields = [ ] ) { $ collection = $ this -> getCollection ( $ collectionName ) ; if ( $ this -> _profilerEnabled ) { $ message = 'db.' . $ collectionName . '.find(' ; if ( empty ( $ criteria ) ) { $ message .= ');' ; } else { $ message .= json_enc...
Find the data from the collection
14,318
public function findFirst ( $ collectionName , array $ criteria = [ ] , array $ fields = [ ] ) { $ collection = $ this -> getCollection ( $ collectionName ) ; if ( $ this -> _profilerEnabled ) { $ message = 'db.' . $ collectionName . '.findOne(' ; if ( empty ( $ criteria ) ) { $ message .= ');' ; } else { $ message .= ...
Find an item of the data from the collection
14,319
public function update ( $ collectionName , array $ criteria , array $ data , array $ options = [ ] ) { $ collection = $ this -> getCollection ( $ collectionName ) ; if ( $ this -> _profilerEnabled ) { $ message = 'db.' . $ collectionName . '.update(' . json_encode ( $ criteria ) . ',' . json_encode ( $ data ) . ');' ;...
Update the data of the collection
14,320
public function remove ( $ collectionName , array $ criteria = [ ] , array $ options = [ ] ) { $ collection = $ this -> getCollection ( $ collectionName ) ; if ( $ this -> _profilerEnabled ) { $ message = 'db.remove(' . json_encode ( $ criteria ) . ');' ; $ event = $ this -> getProfiler ( ) -> startDelete ( $ message )...
Remove the data from the collection
14,321
public function getCollection ( $ collectionName ) { if ( ! isset ( $ this -> collections [ $ collectionName ] ) ) { $ this -> collections [ $ collectionName ] = $ this -> getDatabase ( ) -> selectCollection ( $ collectionName ) ; } return $ this -> collections [ $ collectionName ] ; }
Get the collection
14,322
public function getDatabase ( $ databaseName = null ) { if ( $ databaseName === null ) { $ databaseName = $ this -> dbname ; } if ( ! isset ( $ this -> databases [ $ databaseName ] ) ) { $ this -> databases [ $ databaseName ] = $ this -> getClient ( ) -> selectDB ( $ databaseName ) ; } return $ this -> databases [ $ da...
Get the database
14,323
public function getClient ( ) { if ( $ this -> client === null ) { $ connectionString = $ this -> getConnectionString ( ) ; $ connectionOptions = $ this -> getConnectionOptions ( ) ; if ( $ this -> _profilerEnabled ) { $ event = $ this -> getProfiler ( ) -> startInfo ( 'Connect: ' . $ connectionString ) ; } $ attempts ...
Get the mongo client
14,324
public function getConnectionString ( ) { $ connection = new Url ( 'mongodb' ) ; $ connection -> setPath ( $ this -> dbname ) ; if ( $ this -> username !== null ) { $ connection -> setUsername ( $ this -> username ) ; if ( $ this -> password !== null ) { $ connection -> setPassword ( $ this -> password ) ; } } if ( emp...
Get MongoClient connection string
14,325
protected function assembleHost ( Url $ host ) { if ( ! $ host -> hasHost ( ) ) { $ host -> setHost ( $ this -> defaultHost ) ; } if ( preg_match ( '/\.sock$/i' , $ host -> getHost ( ) ) ) { $ host -> removePort ( ) ; } else if ( ! $ host -> hasPort ( ) ) { $ host -> setPort ( $ this -> defaultPort ) ; } return trim ( ...
Assemble an url from the host parts
14,326
protected function putDetailInfoIntoProfiler ( ) { $ profiler = $ this -> getProfiler ( ) ; if ( ! $ profiler instanceof ProfilerExtendedInterface ) { return ; } try { $ infoRaw = $ this -> getDatabase ( ) -> command ( [ 'buildinfo' => 1 ] ) ; } catch ( Exception $ exception ) { $ profiler -> setAdditionalInfo ( [ 'Bui...
Collect an additional information about the MongoDB and a connection and put it to a profiler
14,327
public function actionShow ( int $ id ) { $ this -> trigger ( self :: EVENT_BEFORE_SHOW , $ this -> getViewedProductEvent ( $ id ) ) ; $ product = Product :: find ( ) -> where ( [ 'show' => true , 'id' => $ id , 'status' => Product :: STATUS_SUCCESS ] ) -> one ( ) ; if ( ! empty ( $ product ) ) { $ this -> setSeoData (...
Shows Product model
14,328
private function setSeoData ( $ product ) { $ view = $ this -> view ; $ titleTemplateSetting = 'seo-title-template-' . Yii :: $ app -> language ; $ descriptionTemplateSetting = 'seo-description-template-' . Yii :: $ app -> language ; if ( ! empty ( $ product -> translation -> seoTitle ) ) { $ title = $ product -> trans...
Sets page title meta - description and meta - keywords .
14,329
public function setSchedule ( $ schedule , $ options = [ ] ) { $ this -> schedule = $ schedule ; $ this -> setOptions ( $ options ) ; return $ this ; }
Sets the value of schedule .
14,330
public function addOverviewItem ( ProductionMenuCollectionEvent $ event ) : void { $ menu = $ event -> getMenu ( ) ; $ group = $ event -> getGroup ( ) ; $ overview = $ this -> factory -> createItem ( 'menu_item.overview' , [ 'route' => 'bkstg_production_overview' , 'routeParameters' => [ 'production_slug' => $ group ->...
Add the overview menu item .
14,331
public function addSettingsItem ( ProductionMenuCollectionEvent $ event ) : void { $ menu = $ event -> getMenu ( ) ; $ group = $ event -> getGroup ( ) ; if ( ! $ this -> auth -> isGranted ( 'GROUP_ROLE_ADMIN' , $ group ) ) { return ; } $ settings = $ this -> factory -> createItem ( 'menu_item.settings' , [ 'route' => '...
Add the settings menu item .
14,332
public function createMigration ( $ name , $ file_extension ) { if ( preg_replace ( '/[a-z\d\._]/' , '' , $ name ) ) { throw new \ InvalidArgumentException ( 'The migration name can consist only from alpha-numeric characters, as well as dots and underscores.' ) ; } if ( ! in_array ( $ file_extension , $ this -> getMigr...
Creates new migration .
14,333
public function run ( MigrationContext $ context ) { $ this -> setContext ( $ context ) ; $ this -> createMigrationsTable ( ) ; $ all_migrations = $ this -> getAllMigrations ( ) ; $ executed_migrations = $ this -> getExecutedMigrations ( ) ; $ migrations_to_execute = array_diff ( $ all_migrations , $ executed_migration...
Executes outstanding migrations .
14,334
protected function setContext ( MigrationContext $ context ) { $ this -> _context = $ context ; $ this -> _context -> setContainer ( $ this -> _container ) ; }
Sets current context .
14,335
protected function createMigrationsTable ( ) { $ db = $ this -> _context -> getDatabase ( ) ; $ sql = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = :table_name" ; $ migrations_table = $ db -> fetchValue ( $ sql , array ( 'table_name' => 'Migrations' ) ) ; if ( $ migrations_table !== false ) { re...
Creates migration table when missing .
14,336
protected function getAllMigrations ( ) { $ migrations = array ( ) ; $ file_extensions = $ this -> getMigrationFileExtensions ( ) ; $ directory_iterator = new \ DirectoryIterator ( $ this -> _migrationsDirectory ) ; foreach ( $ directory_iterator as $ file ) { if ( $ file -> isFile ( ) && in_array ( $ file -> getExtens...
Returns all migrations .
14,337
protected function executeMigrations ( array $ migrations ) { if ( ! $ migrations ) { return ; } $ db = $ this -> _context -> getDatabase ( ) ; foreach ( $ migrations as $ migration ) { $ db -> beginTransaction ( ) ; $ migration_type = pathinfo ( $ migration , PATHINFO_EXTENSION ) ; $ this -> _migrationRunners [ $ migr...
Executes migrations .
14,338
protected function deleteMigrations ( array $ migrations ) { if ( ! $ migrations ) { return ; } $ sql = 'DELETE FROM Migrations WHERE Name IN (:names)' ; $ this -> _context -> getDatabase ( ) -> perform ( $ sql , array ( 'names' => $ migrations ) ) ; }
Deletes migrations .
14,339
public function setPagination ( int $ currentPage = 1 , int $ perPage = 20 , int $ adjacent = 1 , int $ totalCount = 0 ) { $ this -> currentPage = $ currentPage ; $ this -> perPage = $ perPage ; $ this -> adjacent = $ adjacent ; $ this -> totalCount = $ totalCount ; }
Sets pagination properties
14,340
final public function inMiddle ( ) : bool { return ( $ this -> lastPage ( ) - ( $ this -> adjacent * 2 ) > $ this -> currentPage && $ this -> currentPage > ( $ this -> adjacent * 2 ) ) ? TRUE : FALSE ; }
Check if in middle then hide some front and some back
14,341
public function getTotalMetrics ( Project $ project , array $ domains = [ ] , array $ languages = [ ] ) : array { $ metrics = [ ] ; $ masterLanguage = $ project -> getMasterLanguage ( ) ; $ languages = empty ( $ languages ) ? $ project -> getAvailableLanguages ( ) : $ languages ; $ languages = array_intersect ( $ langu...
Get total metrics given a Project .
14,342
public static function root ( $ environments , $ envName , $ projectPath ) { $ root = new static ( ) ; $ root -> environments = $ environments ; $ root -> envName = $ envName ; $ root -> projectPath = $ projectPath ; $ root -> verifyEnv ( $ envName ) ; return $ root ; }
The constructor for ConfigBag .
14,343
public function actionAddAdditional ( int $ productId , int $ languageId ) { $ additionalProductsCategories = Category :: find ( ) -> with ( 'products' ) -> where ( [ 'additional_products' => true ] ) -> all ( ) ; $ productAdditionalProducts = ProductAdditionalProduct :: find ( ) -> where ( [ 'product_id' => $ productI...
Adds additional products
14,344
public function setButtonSubmit ( $ submitButton ) { if ( \ is_string ( $ submitButton ) ) { $ this -> submitButton = CmsButton :: getInstance ( $ submitButton ) ; } elseif ( $ submitButton instanceof CmsButton ) { $ this -> submitButton = $ submitButton ; } else { throw new InvalidArgumentException ( 'setButtonSubmit ...
If ColumnInput is used
14,345
public function addContextMenu ( array $ menu ) { foreach ( $ menu as & $ item ) { if ( ! \ is_array ( $ item ) || ! isset ( $ item [ 'title' ] ) ) { throw new InvalidArgumentException ( 'Invalid structure. Example: [ [\'title\' => \'TEST\', \'href\' => \'http://www.google.com\', \'popup\' => \'true\', \'confirm\' => \...
context menu for table rows with dynamic parameters
14,346
public function create ( $ routeName , array $ data = array ( ) , array $ query = array ( ) ) { if ( strpos ( $ routeName , '@' ) === 0 ) $ route = $ this -> rootRouter -> findRoute ( substr ( $ routeName , 1 ) ) ; else $ route = $ this -> map -> findRoute ( $ routeName ) ; if ( ! $ route ) throw new NotFoundException ...
Create url by route name relative to the given \ Exedra \ Routing \ Group Force an absolute route by prefixing with
14,347
public function current ( array $ query = array ( ) ) { if ( ! $ this -> request ) throw new \ Exedra \ Exception \ InvalidArgumentException ( 'Http Request does not exist.' ) ; $ uri = $ this -> request -> getUri ( ) ; if ( count ( $ query ) > 0 ) { if ( $ uri -> getQuery ( ) ) $ query = http_build_query ( $ query ) ;...
Get current url
14,348
public function getHead ( ) { if ( $ this -> _head === null ) { $ this -> _head = new TablePart ( ) ; $ this -> _head -> setTag ( self :: TAG_HEAD ) ; $ this -> _head -> setHeadPart ( true ) ; } return $ this -> _head ; }
Get the table s head
14,349
public function getBody ( ) { if ( $ this -> _body === null ) { $ this -> _body = new TablePart ( ) ; $ this -> _body -> setTag ( self :: TAG_BODY ) ; } return $ this -> _body ; }
Get the table s body
14,350
public function getFoot ( ) { if ( $ this -> _foot === null ) { $ this -> _foot = new TablePart ( ) ; $ this -> _foot -> setTag ( self :: TAG_FOOT ) ; } return $ this -> _foot ; }
Get the table s foot
14,351
public function render ( $ html = null ) { $ separator = $ this -> getSeparator ( ) ; $ result = '' ; if ( $ this -> _colgroup !== null ) { $ result .= $ separator . $ this -> _colgroup -> render ( ) ; } if ( $ this -> _head !== null ) { $ result .= $ separator . $ this -> _head -> render ( ) ; } if ( $ this -> _body !...
Render the table
14,352
public function getCredentialObject ( $ accountId = null ) { if ( $ accountId == null && array_key_exists ( $ this -> defaultAccountName , $ this -> credentialHashmap ) ) { $ credObj = $ this -> credentialHashmap [ $ this -> defaultAccountName ] ; } elseif ( array_key_exists ( $ accountId , $ this -> credentialHashmap ...
Obtain Credential Object based on StoreId provided .
14,353
public function actionCreate ( ) { if ( ! \ Yii :: $ app -> user -> can ( 'create' ) ) return $ this -> alert ( Module :: t ( 'core' , 'Access denied.' ) ) ; $ model = new Rubric ( ) ; $ request = \ Yii :: $ app -> getRequest ( ) ; $ loaded = $ model -> load ( $ request -> post ( ) ) ; if ( $ loaded && $ model -> prepe...
Creates a new Rubric model . If creation is successful the browser will be redirected to the index page .
14,354
public function actionUpdate ( $ id ) { if ( ! \ Yii :: $ app -> user -> can ( 'update' ) ) return $ this -> alert ( Module :: t ( 'core' , 'Access denied.' ) ) ; $ model = $ this -> findModel ( $ id ) ; if ( $ one = $ model -> parents ( 1 ) -> one ( ) ) { $ model -> parent_node = $ one -> id ; $ loaded = $ model -> lo...
Updates an existing Rubric model . If update is successful the browser will be redirected to the index page .
14,355
public function actionDelete ( $ id ) { if ( ! \ Yii :: $ app -> user -> can ( 'delete' ) ) throw new ForbiddenHttpException ( Module :: t ( 'core' , 'Access denied.' ) ) ; if ( $ id == 1 ) \ Yii :: $ app -> session -> setFlash ( 'warning' , \ Yii :: t ( 'core' , 'Node can not be deleted.' ) ) ; else { $ node = $ this ...
Deletes an existing Rubric model . If deletion is successful the browser will be redirected to the index page .
14,356
protected function findModel ( $ id ) { if ( ( $ model = Rubric :: findOne ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( Module :: t ( 'core' , 'The requested model does not exist.' ) ) ; } }
Finds model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
14,357
public static function toString ( $ nodeOrder ) { $ oClass = new \ ReflectionClass ( __CLASS__ ) ; foreach ( $ oClass -> getConstants ( ) as $ key => $ value ) { if ( $ value == $ nodeOrder ) return $ key ; } return chr ( $ nodeOrder + 65 ) ; }
Returns a string version of the value
14,358
private function decryptRequest ( EncryptionKeyInterface $ key , ServerRequestInterface $ request , string $ rawBody , int $ version ) : ? string { static $ response = null ; static $ nonce = null ; static $ publicKey = null ; $ response = new Response ( $ key -> getBoxSecretKey ( ) ) ; if ( $ version === 1 ) { if ( ! ...
Decrypts a request
14,359
private function getEncryptionKey ( ServerRequestInterface $ request ) : EncryptionKeyInterface { if ( ! $ request -> hasHeader ( 'x-hashid' ) ) { throw new Exception ( 'Unable to decrypt request.' ) ; } $ hashKey = $ request -> getHeaderLine ( 'x-hashid' ) ; try { $ result = $ this -> cache -> get ( $ hashKey ) ; if (...
Determines the key from the X - HashId header
14,360
function formatTime ( $ seconds ) { switch ( true ) { case $ seconds == 0 : return 0 ; case $ seconds < 0.01 : $ time = round ( $ seconds * 1000 , 2 ) . 'ms' ; break ; case $ seconds < 0.1 : $ time = round ( $ seconds * 1000 , 1 ) . 'ms' ; break ; case $ seconds < 1 : $ time = round ( $ seconds * 1000 ) . 'ms' ; break ...
Format the value as a time
14,361
function formatMemory ( $ memory ) { switch ( true ) { case $ memory == 0 : return 0 ; case $ memory < 1024 : $ memory = round ( $ memory ) . 'b' ; break ; case $ memory < 1048576 : $ memory = round ( $ memory / 1024 , 2 ) . 'K' ; break ; case $ memory < 10485760 : $ memory = round ( $ memory / 1024 , 1 ) . 'K' ; break...
Format the value as a memory
14,362
public function parse ( $ source , array $ options = [ ] ) { $ mode = isset ( $ options [ self :: OPTION_MODE ] ) ? ( string ) $ options [ self :: OPTION_MODE ] : self :: SECTIONS_ROOT ; if ( $ mode === self :: SECTIONS_IGNORE ) { return $ this -> parseData ( parse_ini_string ( $ source ) ) ; } if ( $ mode === self :: ...
Parse the ini source
14,363
protected function getSection ( $ sections , $ section , $ inheritance = false ) { if ( isset ( $ sections [ $ section ] ) ) { return $ sections [ $ section ] ; } if ( $ inheritance ) { foreach ( array_keys ( $ sections ) as $ part ) { $ colon = strpos ( $ part , ':' ) ; if ( $ colon === false ) { continue ; } $ succes...
Get the section of a section s set
14,364
protected function parseData ( $ dataRaw ) { $ data = [ ] ; foreach ( $ dataRaw as $ key => $ value ) { $ data = array_replace_recursive ( $ data , $ this -> parseKey ( $ key , $ value ) ) ; } return $ data ; }
Parse a raw ini data
14,365
protected function parseKey ( $ key , $ value ) { $ point = strpos ( $ key , '.' ) ; if ( $ point === false ) { if ( is_array ( $ value ) ) { return [ $ key => array_map ( [ 'ZExt\Components\Std' , 'parseValue' ] , $ value ) ] ; } return [ $ key => Std :: parseValue ( $ value ) ] ; } $ keyCurrent = trim ( substr ( $ ke...
Parse a key of an ini key - value pair
14,366
public function buildQuery ( Form $ form , AbstractQueryBuilder $ queryBuilder ) { $ data = $ form -> getData ( ) ; foreach ( $ data as $ name => $ val ) { if ( isset ( $ val [ 'value' ] ) && $ val [ 'value' ] ) { $ type = $ form -> get ( $ name ) -> getConfig ( ) -> getType ( ) ; if ( is_callable ( array ( $ type , 'g...
Build the QueryBuilder object .
14,367
public function getPrmForUrl ( Form $ form ) { $ ret = array ( ) ; foreach ( $ form -> getData ( ) as $ k => $ data ) { if ( isset ( $ data [ 'value' ] ) ) { $ data [ 'value' ] = $ this -> prepareDataForUrl ( $ data [ 'value' ] , $ form -> get ( $ k ) -> get ( 'value' ) ) ; $ ret [ $ k ] = $ data ; } } return count ( $...
Get parameter from a form for creating a pager URL .
14,368
protected function getHome ( ) { if ( isset ( $ this -> home ) ) { return $ this -> home ; } $ home = getenv ( 'CBT_HOME' ) ; if ( ! $ home ) { if ( defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ) { if ( ! getenv ( 'APPDATA' ) ) { throw new \ RuntimeException ( 'The APPDATA or CBT_HOME environment variable must be set for cb...
Determine the home directory where cbt config files shall be stored .
14,369
public function getAdapter ( ) { if ( $ this -> _adapter === null ) { $ this -> _adapter = $ this -> getLocator ( ) -> get ( self :: DEFAULT_LOGGER_ADAPTER ) ; if ( ! $ this -> _adapter instanceof AdapterInterface ) { throw new NoAdapter ( 'Adapter must implement the "AdapterInterface"' ) ; } } return $ this -> _adapte...
Get a logger s adapter
14,370
public function set ( $ key , $ value = null , $ override = false ) { if ( is_array ( $ key ) ) { $ override = $ value ; foreach ( $ key as $ k => $ val ) { if ( $ override === true ) $ this -> setOverride ( $ k , $ val ) ; else $ this -> data [ $ k ] = $ val ; } return $ this ; } else { if ( $ override === true ) $ th...
Set form data
14,371
public function setOverride ( $ key , $ value = null ) { if ( is_array ( $ key ) ) foreach ( $ key as $ k => $ val ) $ this -> override [ $ k ] = $ val ; else $ this -> override [ $ key ] = $ value ; return $ this ; }
Set overriding data
14,372
public function has ( $ key ) { return isset ( $ this -> override [ $ key ] ) ? true : ( isset ( $ this -> data [ $ key ] ) ? true : false ) ; }
Check data existence
14,373
public function get ( $ key , $ default = null ) { return isset ( $ this -> override [ $ key ] ) ? $ this -> override [ $ key ] : ( isset ( $ this -> data [ $ key ] ) ? $ this -> data [ $ key ] : $ default ) ; }
Get form data
14,374
protected function createInput ( $ type , $ name = null , $ value = null , $ attr = null ) { if ( $ type == 'textarea' ) $ input = new Input \ Textarea ( $ name ) ; else $ input = new Input \ Input ( $ type , $ name ) ; if ( $ name ) $ input -> attr ( 'id' , $ name ) ; if ( $ value ) $ input -> value ( $ value ) ; else...
Create html input
14,375
public function select ( $ name = null , array $ options = array ( ) , $ value = null , $ attr = null , $ first = null ) { $ select = new Input \ Select ( $ name ) ; if ( $ name ) $ select -> attr ( 'id' , $ name ) ; if ( count ( $ options ) > 0 ) $ select -> options ( $ options ) ; elseif ( isset ( $ this -> dataOptio...
Create select input
14,376
public function text ( $ name = null , $ value = null , $ attr = null ) { return $ this -> createInput ( 'text' , $ name , $ value , $ attr ) ; }
Create html text input
14,377
public function password ( $ name = null , $ value = null , $ attr = null ) { return $ this -> createInput ( 'password' , $ name , $ value , $ attr ) ; }
Create html password input
14,378
public function textarea ( $ name = null , $ value = null , $ attr = null ) { return $ this -> createInput ( 'textarea' , $ name , $ value , $ attr ) ; }
Create html textarea input
14,379
public function date ( $ name = null , $ value = null , $ attr = null ) { return $ this -> createInput ( 'date' , $ name , $ value , $ attr ) ; }
Create html 5 date input
14,380
public function time ( $ name = null , $ value = null , $ attr = null ) { return $ this -> createInput ( 'time' , $ name , $ value , $ attr ) ; }
Create html 5 time input
14,381
public function file ( $ name = null , $ value = null , $ attr = null ) { return $ this -> createInput ( 'file' , $ name , $ value , $ attr ) ; }
Create html file input
14,382
public function hidden ( $ name = null , $ value = null , $ attr = null ) { return $ this -> createInput ( 'hidden' , $ name , $ value , $ attr ) ; }
Create html hidden input
14,383
public function checkbox ( $ name = null , $ value = null , $ status = false , $ attr = null ) { $ input = $ this -> createInput ( 'checkbox' , $ name , $ value , $ attr ) ; if ( $ status ) $ input -> attr ( 'checked' , true ) ; return $ input ; }
Create html checkbox input
14,384
public function submit ( $ name = null , $ value = null , $ attr = null ) { return $ this -> createInput ( 'submit' , $ name , $ value , $ attr ) ; }
Create html submit input
14,385
public function getContent ( ) { $ content = file_get_contents ( $ this -> getRealpath ( ) ) ; if ( $ content === false ) { throw new Exceptions \ InvalidPath ( 'File "' . $ this -> path . '" is unreadable' , null , null , $ this -> path ) ; } return $ content ; }
Get content of file
14,386
public function getRealpath ( ) { if ( $ this -> realpath === null ) { $ this -> realpath = realpath ( $ this -> path ) ; if ( $ this -> realpath === false ) { throw new Exceptions \ InvalidPath ( 'Path "' . $ this -> path . '" doesn\'t exists or inaccsessible' , null , null , $ this -> path ) ; } } return $ this -> re...
Get full path to file
14,387
public function getExtension ( ) { $ dotPos = strrpos ( $ this -> path , '.' ) ; if ( $ dotPos === false ) { return ; } return substr ( $ this -> path , $ dotPos + 1 ) ; }
Get extension of file
14,388
private function deactivateQuote ( $ quote ) { $ quoteId = $ quote -> getId ( ) ; if ( $ this -> sessCustomer -> isLoggedIn ( ) ) { $ this -> daoWrhsQuote -> deleteById ( $ quoteId ) ; } else { $ quoteReg = $ this -> sessCustomer -> getData ( AQuoteRepo :: SESS_QUOTE_REGISTRY ) ; if ( is_array ( $ quoteReg ) && isset (...
Remove placed quote from warehouse registry .
14,389
public function configure ( $ filename ) { require $ filename ; $ this -> employees = $ employees ; $ this -> pipeline = new Pipeline ( $ pipelineBackend ) ; if ( isset ( $ schedulerBackend ) ) { $ this -> scheduler = new Scheduler ( $ schedulerBackend ) ; } }
Configure with PHP code from a file .
14,390
public function init ( ) { $ slug = Helpers :: urlize ( $ this -> getModel ( ) -> getSlug ( ) ) ; $ this -> getModel ( ) -> setSlug ( $ slug ) ; if ( in_array ( $ slug , $ this -> forbidden_slugs ) ) { throw new PosttypeException ( Translate :: t ( 'posttype.errors.slug_is_forbidden' ) ) ; } if ( ! in_array ( $ slug , ...
Build PosttypeModel and initialize hook .
14,391
public function defaultStatuses ( $ name ) { return [ 'label' => $ name , 'public' => false , 'internal' => false , 'exclude_from_search' => false , 'show_in_admin_all_list' => true , 'show_in_admin_status_list' => false , 'label_count' => Translate :: n ( $ name . ' <span class="count">(%s)</span>' , $ name . ' <span ...
Build statuses .
14,392
public function transform ( $ entity ) { if ( null === $ entity || '' === $ entity ) { return null ; } if ( ! is_object ( $ entity ) ) { throw new UnexpectedTypeException ( $ entity , 'object' ) ; } return $ this -> accessor -> getValue ( $ entity , $ this -> identifier ) ; }
Transforms entity to id
14,393
public function reverseTransform ( $ value ) { if ( '' === $ value || null === $ value ) { return null ; } if ( ! is_scalar ( $ value ) ) { throw new TransformationFailedException ( 'Value is not scalar' ) ; } try { $ hash = $ this -> getCacheHash ( $ value ) ; if ( array_key_exists ( $ hash , $ this -> cachedResults )...
Tranforms id to entity
14,394
private function httpPost ( $ host , $ path , $ data , $ port = 80 ) { $ req = $ this -> getQSEncode ( $ data ) ; $ httpRequest = "POST $path HTTP/1.0\r\n" ; $ httpRequest .= "Host: $host\r\n" ; $ httpRequest .= "Content-Type: application/x-www-form-urlencoded;\r\n" ; $ httpRequest .= "Content-Length: " . strlen ( $ re...
Submits an HTTP POST to a reCAPTCHA server
14,395
private function getQSEncode ( $ data ) { $ req = null ; foreach ( $ data as $ key => $ value ) { $ req .= $ key . '=' . urlencode ( stripslashes ( $ value ) ) . '&' ; } $ req = substr ( $ req , 0 , strlen ( $ req ) - 1 ) ; return $ req ; }
Encodes the given data into a query string format
14,396
public function AddHeader ( $ name , $ enabled = true ) { if ( ! isset ( $ this -> headers [ $ name ] ) ) { $ header = new Element \ Header ( $ name , $ enabled ) ; $ this -> headers [ $ name ] = $ header ; } }
Add a header file .
14,397
public function AddConstant ( \ Peg \ Lib \ Definitions \ Element \ Constant $ constant , $ header , $ namespace = "\\" ) { $ this -> AddHeader ( $ header ) ; $ this -> headers [ $ header ] -> AddConstant ( $ constant , $ namespace ) ; }
Adds a constant to the symbols table .
14,398
public function AddEnumeration ( \ Peg \ Lib \ Definitions \ Element \ Enumeration $ enumeration , $ header , $ namespace = "\\" ) { $ this -> AddHeader ( $ header ) ; $ this -> headers [ $ header ] -> AddEnumeration ( $ enumeration , $ namespace ) ; }
Adds an enumeration to the symbols table .
14,399
public function AddTypeDef ( \ Peg \ Lib \ Definitions \ Element \ TypeDef $ typedef , $ header , $ namespace = "\\" ) { $ this -> AddHeader ( $ header ) ; $ this -> headers [ $ header ] -> AddTypeDef ( $ typedef , $ namespace ) ; }
Adds a type definition to the symbols table .