idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
11,900
public function add ( ) { $ this -> view = 'scaffold/add' ; $ form = new Form ( "add-{$this->get('modelSingular')}" , $ this -> getDescriptor ( ) ) ; if ( $ this -> request -> isPost ( ) ) { $ form -> setData ( $ this -> request -> getPost ( ) ) ; if ( $ form -> isValid ( ) ) { try { $ modelClass = $ this -> getModelNa...
Handles the request to add page
11,901
public function edit ( $ recordId = 0 ) { $ this -> view = 'scaffold/edit' ; $ recordId = StaticFilter :: filter ( 'number' , $ recordId ) ; $ record = call_user_func_array ( [ $ this -> getModelName ( ) , 'get' ] , [ $ recordId ] ) ; if ( is_null ( $ record ) ) { $ this -> addWarningMessage ( "The {$this->get('modelSi...
Handles the request to edit page
11,902
public function delete ( ) { if ( $ this -> request -> isPost ( ) ) { $ recordId = StaticFilter :: filter ( 'text' , $ this -> request -> getPost ( 'id' ) ) ; $ record = call_user_func_array ( [ $ this -> getModelName ( ) , 'get' ] , [ $ recordId ] ) ; if ( is_null ( $ record ) ) { $ this -> addWarningMessage ( "The {$...
Handles the request to delete a record
11,903
public function unserialize ( $ serialized ) { $ data = unserialize ( $ serialized ) ; $ this -> inspector = new Inspector ( $ this ) ; foreach ( $ data as $ key => $ value ) { $ this -> $ key = $ value ; } return $ this ; }
Creates a new object from serialized data
11,904
public function init ( ) { Yii :: app ( ) -> getModule ( 'audit' ) ; if ( $ this -> catchFatalErrors ) { register_shutdown_function ( array ( $ this , 'handleFatalError' ) ) ; if ( substr ( php_sapi_name ( ) , 0 , 3 ) != 'cli' ) { ob_start ( array ( $ this , 'handleFatalBuffer' ) ) ; } } if ( $ this -> trackAllRequests...
Init the error handler register a shutdown function to catch fatal errors and track the request .
11,905
public function handleFatalError ( ) { $ e = error_get_last ( ) ; if ( $ e !== null && in_array ( $ e [ 'type' ] , $ this -> fatalErrorTypes ) ) { $ event = new CErrorEvent ( $ this , 500 , 'Fatal error: ' . $ e [ 'message' ] , $ e [ 'file' ] , $ e [ 'line' ] ) ; $ this -> handle ( $ event ) ; } }
Fatal error handler
11,906
public function handleFatalBuffer ( $ buffer ) { $ e = error_get_last ( ) ; return ( $ e !== null && in_array ( $ e [ 'type' ] , $ this -> fatalErrorTypes ) ) ? '' : $ buffer ; }
Clears the output buffer that was set in init if there was a fatal error .
11,907
public function handle ( $ event ) { if ( $ event instanceof CExceptionEvent ) $ this -> logExceptionEvent ( $ event ) ; else $ this -> logErrorEvent ( $ event ) ; parent :: handle ( $ event ) ; }
Log the pretty html stack dump before the parent handles the error .
11,908
public function endAuditRequest ( ) { $ auditRequest = $ this -> getAuditRequest ( ) ; if ( ! in_array ( 'response_headers' , $ this -> auditRequestIgnoreFields ) && function_exists ( 'headers_list' ) ) { $ auditRequest -> response_headers = headers_list ( ) ; } if ( $ auditRequest -> response_headers ) { foreach ( $ a...
Callback to update the AuditRequest at the end of the Yii request .
11,909
private function getCurrentLink ( ) { if ( Yii :: app ( ) instanceof CWebApplication ) { return Yii :: app ( ) -> getRequest ( ) -> getHostInfo ( ) . Yii :: app ( ) -> getRequest ( ) -> getUrl ( ) ; } $ link = 'yiic ' ; if ( isset ( $ _SERVER [ 'argv' ] ) ) { $ argv = $ _SERVER [ 'argv' ] ; array_shift ( $ argv ) ; $ l...
Gets a link to the current page or yiic script that is being run .
11,910
private function removeValuesWithPasswordKeys ( $ array , & $ passwordRemoved = false ) { foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ value = $ this -> removeValuesWithPasswordKeys ( $ value , $ removedChild ) ; if ( $ removedChild ) { $ array [ $ key ] = $ value ; $ passwordRemoved = true...
Removes passwords from the given array .
11,911
private function getShrinkedSession ( ) { $ serialized = '' ; if ( isset ( $ _SESSION ) ) { $ serialized = serialize ( $ _SESSION ) ; } if ( strlen ( $ serialized ) > 64000 ) { $ sessionCopy = $ _SESSION ; $ ignoredKeys = array ( ) ; foreach ( $ _SESSION as $ key => $ value ) { $ size = strlen ( serialize ( $ value ) )...
Shrinks the session of huge datafields to prevent too much data being stored .
11,912
public function AddElement ( $ name , $ data ) { $ this -> factory -> addElement ( $ this , $ name , $ data ) ; return $ this ; }
Adds an element to the form using the built in factory
11,913
public function setEventManager ( EventManagerInterface $ eventManager ) { $ eventManager -> setIdentifiers ( array ( __CLASS__ , get_called_class ( ) , $ this -> getName ( ) ) ) ; $ this -> _events = $ eventManager ; return $ this ; }
Inject an EventManager instance
11,914
public function render ( ) { $ this -> getEventManager ( ) -> trigger ( 'formBeforeRender' , $ this , array ( ) ) ; $ output = parent :: render ( ) ; $ this -> getEventManager ( ) -> trigger ( 'formAfterRender' , $ this , array ( 'output' => & $ output ) ) ; return $ output ; }
Renders the form as HTML string
11,915
public function mock ( $ str ) { fputs ( $ this -> inputStream , $ str ) ; rewind ( $ this -> inputStream ) ; return $ this ; }
Mock an input string
11,916
protected function _constraintsStatement ( ) { $ cons = $ this -> _sql -> getConstraints ( ) ; if ( empty ( $ cons ) ) { return null ; } return $ this -> _parseConstraints ( ) ; }
Parse column list for SQL add constraint statement
11,917
protected function _droppedColumnsStatement ( ) { $ columns = $ this -> _sql -> getDroppedColumns ( ) ; if ( empty ( $ columns ) ) { return null ; } return implode ( ', ' , array_keys ( $ columns ) ) ; }
Parse column list for SQL drop column statement
11,918
protected function _addColumnsStatement ( ) { $ columns = $ this -> _sql -> getColumns ( ) ; if ( empty ( $ columns ) ) { return null ; } return $ this -> _parseColumns ( ) ; }
Parse column list for SQL add column statement
11,919
public function getRelatedForeignKey ( ) { if ( is_null ( $ this -> _relatedForeignKey ) ) { $ tblName = Entity \ Manager :: getInstance ( ) -> get ( $ this -> _relatedEntity ) -> getEntity ( ) -> getTableName ( ) ; $ name = Text :: singular ( $ tblName ) ; $ this -> setRelatedForeignKey ( "{$name}_id" ) ; } return $ t...
Returns related foreign key . If its not set tries to infer it from related table name .
11,920
public function getRelationTable ( ) { if ( is_null ( $ this -> _relationTable ) ) { $ names = [ $ this -> getEntity ( ) -> getTableName ( ) , Entity \ Manager :: getInstance ( ) -> get ( $ this -> _relatedEntity ) -> getEntity ( ) -> getTableName ( ) ] ; asort ( $ names ) ; $ this -> setRelationTable ( implode ( '_' ,...
Returns relation table name . If its not set tries to infer it from related table names .
11,921
public function setEntity ( Entity $ entity ) { $ events = $ this -> getContainer ( ) -> get ( 'sharedEventManager' ) ; $ name = $ entity -> getClassName ( ) ; $ events -> attach ( $ name , Delete :: BEFORE_DELETE , [ $ this , 'beforeDelete' ] ) ; $ events -> attach ( $ name , Save :: AFTER_SAVE , [ $ this , 'afterSave...
Sets the entity that defines the relation . Sets the triggers for before delete event .
11,922
public function beforeDelete ( Delete $ event ) { $ pmkVal = $ event -> primaryKey ; $ entFrk = $ this -> getForeignKey ( ) ; Sql :: createSql ( $ this -> getEntity ( ) -> getAdapter ( ) ) -> delete ( $ this -> getRelationTable ( ) ) -> where ( [ "{$entFrk} = :id" => [ ":id" => $ pmkVal ] ] ) -> execute ( ) ; }
Deletes all relational data on deleting entity
11,923
public function afterSave ( Save $ event ) { $ entity = $ event -> getTarget ( ) ; $ entity -> loadRelations = false ; $ prop = $ this -> getPropertyName ( ) ; $ relPrk = Entity \ Manager :: getInstance ( ) -> get ( $ this -> getRelatedEntity ( ) ) -> getEntity ( ) -> getPrimaryKey ( ) ; $ entPrk = $ entity -> getPrima...
Handles the after save event
11,924
public function getTemplate ( ) { if ( is_null ( $ this -> _template ) ) { $ this -> _template = new \ Slick \ Form \ Template \ SelectMultiple ( ) ; } return $ this -> _template ; }
lazy loads a default template for this element
11,925
public function ColumnsList ( ) { $ list = new ArrayList ( ) ; foreach ( $ this -> columns as $ key => $ column ) { $ header = $ this -> array_get ( $ column , self :: KEY_HEADER ) ; $ required = $ this -> array_get ( $ column , self :: KEY_REQUIRED ) ; $ type = $ this -> array_get ( $ column , self :: KEY_TYPE , self ...
Return an array list of columns
11,926
public function getMetaData ( ) { $ metaData = parent :: getMetaData ( ) ; if ( $ metaData ) return $ metaData ; $ className = get_class ( $ this ) ; if ( empty ( self :: $ _md [ $ className ] ) ) { self :: $ _md [ $ className ] = null ; self :: $ _md [ $ className ] = new CActiveRecordMetaData ( $ this ) ; } return se...
Returns the meta - data for this AR
11,927
public function tableName ( ) { $ audit = Yii :: app ( ) -> getModule ( 'audit' ) ; if ( ! empty ( $ audit -> modelMap [ get_class ( $ this ) ] [ 'tableName' ] ) ) return $ audit -> modelMap [ get_class ( $ this ) ] [ 'tableName' ] ; return strtolower ( preg_replace ( '/([a-z])([A-Z])/' , '$1_$2' , get_class ( $ this )...
Guess the table name based on the class
11,928
public function getRegisteredHelper ( $ name ) { if ( array_key_exists ( $ name , $ this -> helpers ) ) { return $ this -> helpers [ $ name ] ; } throw new Exceptions \ RegisteredHelperClassNotFoundException ( $ name ) ; }
Returns the class name specified against a registered helper class
11,929
public function load ( $ name ) { $ helper = $ this -> getRegisteredHelper ( $ name ) ; $ reflection = new \ ReflectionClass ( $ helper ) ; $ class = $ reflection -> newInstance ( $ this -> di ) ; return $ class ; }
Creates and returns an instance of the helper
11,930
public function all ( ) { $ events = $ this -> _entity -> getEventManager ( ) ; $ event = new SelectEvent ( [ 'sqlQuery' => & $ this , 'params' => [ ] , 'action' => SelectEvent :: FIND_ALL , 'singleItem' => false ] ) ; $ events -> trigger ( SelectEvent :: BEFORE_SELECT , $ this -> _entity , $ event ) ; $ result = paren...
Return all the records for the current query
11,931
public function first ( ) { $ events = $ this -> _entity -> getEventManager ( ) ; $ event = new SelectEvent ( [ 'sqlQuery' => & $ this , 'params' => [ ] , 'action' => SelectEvent :: FIND_FIRST , 'singleItem' => true ] ) ; $ events -> trigger ( SelectEvent :: BEFORE_SELECT , $ this -> _entity , $ event ) ; $ row = paren...
Returns the first record for the current query
11,932
public function getTemplate ( ) { if ( is_null ( $ this -> _template ) ) { Template :: appendPath ( dirname ( __FILE__ ) . '/Views' ) ; $ temp = new Template ( ) ; $ this -> _template = $ temp -> initialize ( ) ; } return $ this -> _template ; }
Returns current template interface
11,933
public function load ( $ className ) { $ this -> reflection = new \ ReflectionClass ( $ className ) ; $ this -> reader = $ this -> annotation -> get ( $ className ) ; $ this -> className = $ className ; return $ this ; }
Loads the command and creates a reflection entity for it .
11,934
public function describe ( ) { $ methods = array ( ) ; $ methodAnnotations = $ this -> reader -> getMethodsAnnotations ( ) ; foreach ( $ this -> reflection -> getMethods ( ) as $ method ) { $ name = $ method -> getName ( ) ; if ( isset ( $ methodAnnotations [ $ name ] ) ) { if ( $ methodAnnotations [ $ name ] -> has ( ...
Describes a task for the library
11,935
public function prep ( $ action = null ) { $ method = $ this -> getSetupMethod ( $ action ) ; if ( ! is_null ( $ method ) ) { $ method -> invokeArgs ( $ this -> reflection -> newInstance ( ) , array ( 'action' => $ action ) ) ; } $ this -> sortParams ( ) ; }
Looks for defined arguments and options and validates them
11,936
public function getSetupMethod ( $ action ) { if ( $ this -> reflection -> hasMethod ( 'setup' . ucwords ( $ action ) ) ) { return $ this -> reflection -> getMethod ( 'setup' . ucwords ( $ action ) ) ; } elseif ( $ this -> reflection -> hasMethod ( 'setup' ) ) { return $ this -> reflection -> getMethod ( 'setup' ) ; } ...
Gets the setup method used by the task
11,937
public function sortArguments ( ) { $ arguments = array ( ) ; $ expectedArguments = $ this -> di -> get ( 'argument' ) -> getExpectedOrder ( ) ; foreach ( $ expectedArguments as $ pos => $ key ) { if ( array_key_exists ( $ pos , $ this -> arguments ) ) { $ arguments [ $ key ] = $ this -> di -> get ( 'argument' ) -> val...
Sorts out arguments into their correct orders
11,938
public function sortOptions ( ) { $ options = array ( ) ; $ expectedOptions = $ this -> di -> get ( 'option' ) -> getExpectedOrder ( ) ; foreach ( $ expectedOptions as $ pos => $ key ) { if ( array_key_exists ( $ pos , $ this -> options ) ) { $ options [ $ key ] = $ this -> di -> get ( 'option' ) -> validate ( $ key , ...
Sorts out options into correct orders
11,939
public function loadParams ( array $ params ) { $ this -> arguments = array ( ) ; $ this -> options = array ( ) ; foreach ( $ params as $ param ) { if ( strpos ( $ param , '-' ) !== false ) { $ this -> options [ ] = $ this -> extractOption ( $ param ) ; } else { $ this -> arguments [ ] = $ param ; } } return $ this ; }
Loads params and splits them into arguments and options
11,940
public function extractOption ( $ str ) { if ( strpos ( $ str , '=' ) ) { $ extraction = explode ( '=' , $ str ) ; return trim ( str_replace ( array ( '\'' , '"' ) , '' , $ extraction [ 1 ] ) ) ; } return true ; }
extracts the option value from an option or boolean
11,941
public function get ( SlickOrmDescriptor $ descriptor ) { $ name = $ descriptor -> getEntity ( ) -> getClassName ( ) ; if ( ! isset ( $ this -> _models [ $ name ] ) ) { $ this -> _models [ $ name ] = new Descriptor ( [ 'descriptor' => $ descriptor ] ) ; } return $ this -> _models [ $ name ] ; }
Return a model descriptor for given entity descriptor
11,942
public function delete ( ) { if ( $ this -> details -> isDir ( ) ) { return @ rmdir ( $ this -> details -> getRealPath ( ) ) ; } return @ unlink ( $ this -> details -> getRealPath ( ) ) ; }
Deletes current node .
11,943
public function getMethod ( $ name ) { return ( isset ( $ this -> _methods [ $ name ] ) ) ? $ this -> _methods [ $ name ] : null ; }
Returns the method with provided name
11,944
public function makeOtherFields ( Blueprint $ table ) { if ( count ( config ( 'categories.other_fields' ) ) > 0 ) { foreach ( config ( 'categories.other_fields' ) as $ filed ) { if ( isset ( $ filed [ 'values' ] ) && $ filed [ 'values' ] != null ) { if ( isset ( $ filed [ 'nullable' ] ) && $ filed [ 'nullable' ] != fal...
set new fields to category table
11,945
public function getKeys ( $ pattern = null ) { $ keys = $ this -> get ( '__stored_keys__' , [ ] ) ; if ( is_null ( $ pattern ) ) { return $ keys ; } $ matches = [ ] ; $ pattern = $ this -> _normalizePattern ( $ pattern ) ; foreach ( $ keys as $ key ) { if ( preg_match ( $ pattern , $ key ) ) { $ matches [ ] = $ key ; }...
Return current keys in use
11,946
protected function _addKey ( $ key ) { if ( $ key == '__stored_keys__' ) { return $ this ; } $ keys = $ this -> get ( '__stored_keys__' , [ ] ) ; if ( ! in_array ( $ key , $ keys ) ) { array_push ( $ keys , $ key ) ; } $ this -> set ( '__stored_keys__' , $ keys , 24 * 60 * 60 ) ; return $ this ; }
Adds a key to the list of keys used
11,947
protected function _parseColumn ( Column \ ColumnInterface $ column ) { $ method = static :: $ _columnMethods [ get_class ( $ column ) ] ; return call_user_func_array ( [ $ this , $ method ] , array ( $ column ) ) ; }
Parses a given column and returns the SQL statement for it
11,948
protected function _parseConstraints ( ) { $ parts = [ ] ; foreach ( $ this -> _sql -> getConstraints ( ) as $ constraint ) { $ cons = $ this -> _parseConstraint ( $ constraint ) ; if ( $ cons ) { $ parts [ ] = $ cons ; } } return implode ( ', ' , $ parts ) ; }
Parse constraint list for SQL create statement
11,949
protected function _parseConstraint ( Constraint \ ConstraintInterface $ cons ) { $ method = static :: $ _constraintMethods [ get_class ( $ cons ) ] ; return call_user_func_array ( [ $ this , $ method ] , array ( $ cons ) ) ; }
Parses a given constraint and returns the SQL statement for it
11,950
protected function _getFKConstraint ( Constraint \ ForeignKey $ cons ) { $ onDelete = '' ; if ( $ cons -> getOnDelete ( ) ) { $ onDelete = " ON DELETE {$cons->getOnDelete()}" ; } $ onUpdated = '' ; if ( $ cons -> getOnUpdate ( ) ) { $ onUpdated = " ON UPDATE {$cons->getOnUpdate()}" ; } return sprintf ( 'CONSTRAINT %s F...
Parse a Foreign Key constraint to its SQL representation
11,951
protected function _getBlobColumn ( Column \ Blob $ column ) { return sprintf ( '%s BLOB%s%s' , $ column -> getName ( ) , $ this -> _columnLength ( $ column ) , $ this -> _nullableColumn ( $ column ) ) ; }
Parses a Blob column to its SQL representation
11,952
protected function _getDateTimeColumn ( Column \ DateTime $ column ) { return sprintf ( '%s TIMESTAMP%s' , $ column -> getName ( ) , $ this -> _nullableColumn ( $ column ) ) ; }
Parses a DateTime column to its SQL representation
11,953
protected function _getFloatColumn ( Column \ Float $ column ) { if ( is_null ( $ column -> getDecimal ( ) ) ) { return sprintf ( '%s FLOAT(%s)' , $ column -> getName ( ) , $ column -> getDigits ( ) ) ; } return sprintf ( '%s DECIMAL(%s, %s)' , $ column -> getName ( ) , $ column -> getDigits ( ) , $ column -> getDecima...
Parses a Float column to its SQL representation
11,954
protected function _getVarcharColumn ( Column \ Varchar $ column ) { return sprintf ( '%s VARCHAR%s NOT NULL' , $ column -> getName ( ) , $ this -> _columnLength ( $ column ) ) ; }
Parses a varchar column to its SQL representation
11,955
public function getIntegerPart ( ) { if ( '0' === $ this -> coefficient ) { return $ this -> coefficient ; } if ( 0 === $ this -> exponent ) { return $ this -> coefficient ; } if ( $ this -> exponent >= strlen ( $ this -> coefficient ) ) { return '0' ; } return substr ( $ this -> coefficient , 0 , - $ this -> exponent ...
Returns the integer part of the number . Note that this does NOT include the sign .
11,956
public function getFractionalPart ( ) { if ( 0 === $ this -> exponent || '0' === $ this -> coefficient ) { return '0' ; } if ( $ this -> exponent > strlen ( $ this -> coefficient ) ) { return str_pad ( $ this -> coefficient , $ this -> exponent , '0' , STR_PAD_LEFT ) ; } return substr ( $ this -> coefficient , - $ this...
Returns the fractional part of the number . Note that this does NOT include the sign .
11,957
public function equals ( self $ number ) { return ( $ this -> isNegative === $ number -> isNegative && $ this -> coefficient === $ number -> getCoefficient ( ) && $ this -> exponent === $ number -> getExponent ( ) ) ; }
Indicates if this number equals another one
11,958
private function initFromString ( $ number ) { if ( ! preg_match ( "/^(?<sign>[-+])?(?<integerPart>\d+)(?:\.(?<fractionalPart>\d+))?$/" , $ number , $ parts ) ) { throw new \ InvalidArgumentException ( sprintf ( '"%s" cannot be interpreted as a number' , print_r ( $ number , true ) ) ) ; } $ this -> isNegative = ( '-' ...
Initializes the number using a string
11,959
private function initFromScientificNotation ( $ coefficient , $ exponent ) { if ( $ exponent < 0 ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid value for exponent. Expected a positive integer or 0, but got "%s"' , $ coefficient ) ) ; } if ( ! preg_match ( "/^(?<sign>[-+])?(?<integerPart>\d+)$/" , $ coeff...
Initializes the number using a coefficient and exponent
11,960
private function removeTrailingZeroesIfNeeded ( ) { $ exponent = $ this -> getExponent ( ) ; $ coefficient = $ this -> getCoefficient ( ) ; if ( 0 < $ exponent && '0' === substr ( $ coefficient , - 1 ) ) { $ fractionalPart = $ this -> getFractionalPart ( ) ; $ trailingZeroesToRemove = 0 ; for ( $ i = $ exponent - 1 ; $...
Removes trailing zeroes from the fractional part and adjusts the exponent accordingly
11,961
public function getRouter ( ) { if ( is_null ( $ this -> _router ) ) { $ this -> _router = new Router ( $ this ) ; } return $ this -> _router ; }
Lazy loads the router object
11,962
public function setEventManager ( EventManagerInterface $ events ) { $ events -> setIdentifiers ( array ( __CLASS__ , get_class ( $ this ) ) ) ; $ events -> setSharedManager ( $ this -> getContainer ( ) -> get ( "sharedEventManager" ) ) ; $ this -> _events = $ events ; return $ this ; }
Sets event manager
11,963
public function getConfiguration ( ) { if ( is_null ( $ this -> _configuration ) ) { $ config = $ this -> getContainer ( ) -> get ( 'configuration' ) ; $ this -> _configuration = $ config ; } return $ this -> _configuration ; }
Returns the configuration settings
11,964
public function getDispatcher ( ) { if ( is_null ( $ this -> _dispatcher ) ) { $ this -> setDispatcher ( new Dispatcher ( [ 'application' => $ this ] ) ) ; } return $ this -> _dispatcher ; }
Returns the request dispatcher
11,965
protected function _startErrorHandler ( ) { $ this -> _whoops = new Run ( ) ; $ environment = $ this -> getConfiguration ( ) -> get ( 'environment' , 'production' ) ; switch ( $ environment ) { case 'production' : $ handler = new Production ( ) ; $ handler -> setApplication ( $ this ) ; break ; default : $ handler = ne...
Starts and registers the error handler
11,966
public static function singular ( $ string ) { $ result = $ string ; foreach ( self :: $ _singular as $ rule => $ replacement ) { $ rule = self :: _normalize ( $ rule ) ; if ( preg_match ( $ rule , $ string ) ) { $ result = preg_replace ( $ rule , $ replacement , $ string ) ; break ; } } return $ result ; }
Returns the singular version of the given string .
11,967
public static function plural ( $ string ) { $ result = $ string ; foreach ( self :: $ _plural as $ rule => $ replacement ) { $ rule = self :: _normalize ( $ rule ) ; if ( preg_match ( $ rule , $ string ) ) { $ result = preg_replace ( $ rule , $ replacement , $ string ) ; break ; } } return $ result ; }
Returns the plural version of the given string .
11,968
public static function split ( $ string , $ pattern , $ limit = null ) { $ flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ; return preg_split ( self :: _normalize ( $ pattern ) , $ string , $ limit , $ flags ) ; }
Split string by a regular expression .
11,969
private static function _normalize ( $ pattern ) { return self :: $ _delimiter . trim ( $ pattern , self :: $ _delimiter ) . self :: $ _delimiter ; }
Normalize the given pattern
11,970
private function setup ( ) { $ this [ 'licenser' ] = function ( ) { return new Licenser ( new Finder ( ) ) ; } ; $ this [ 'command.licenser' ] = function ( $ c ) { return new LicenserCommand ( $ c [ 'licenser' ] , $ c [ 'license_header_factory' ] ) ; } ; $ this [ 'command.check' ] = function ( $ c ) { return new CheckC...
Setup service configuration .
11,971
public function getQueryString ( ) { $ dialect = Dialect :: create ( $ this -> _adapter -> getDialect ( ) , $ this ) ; return $ dialect -> getSqlStatement ( ) ; }
Returns the string version of this query
11,972
public function getFolder ( ) { if ( is_null ( $ this -> _folder ) ) { $ this -> _folder = new Folder ( array ( 'name' => "{$this->_path}/{$this->_dirName}" , 'autoCreate' => true ) ) ; } return $ this -> _folder ; }
Lazy loading of folder property
11,973
public function flush ( ) { foreach ( $ this -> getFolder ( ) -> getNodes ( ) as $ node ) { if ( $ node -> details -> isFile ( ) ) { $ node -> delete ( ) ; } } return $ this ; }
Flushes all values controlled by this cache driver
11,974
public function getHtmlAttributes ( ) { if ( $ this -> getValue ( ) ) { $ this -> _attributes [ 'checked' ] = 'checked' ; } $ text = parent :: getHtmlAttributes ( ) ; $ text = str_replace ( 'form-control' , '' , $ text ) ; return $ text ; }
Overrides the default method to remove the class form - control
11,975
public static function buildContainer ( array $ definitions ) { $ builder = new static ( ) ; $ container = Container :: getContainer ( ) ; $ manager = $ builder -> _createManager ( $ definitions ) ; if ( ! $ container ) { $ container = new Container ( $ manager ) ; } else { $ builder -> _merge ( $ container -> getDefin...
Builds a dependency container with provided definitions
11,976
protected function _createManager ( array $ definitions ) { $ manager = new DefinitionManager ( ) ; foreach ( $ definitions as $ name => $ definition ) { if ( $ definition instanceof DefinitionHelperInterface ) { $ manager -> add ( $ definition -> getDefinition ( $ name ) ) ; } else if ( $ definition instanceof EntryRe...
Creates a definition manager for provided definitions
11,977
protected function _merge ( DefinitionManager $ current , DefinitionManager $ new ) { foreach ( $ new as $ definition ) { if ( ! $ current -> has ( $ definition -> getName ( ) ) ) { $ current -> add ( $ definition ) ; } } }
Adds new definitions to the current definitions manager
11,978
public function make ( $ name , array $ parameters = [ ] ) { if ( ! is_string ( $ name ) ) { throw new InvalidArgumentException ( sprintf ( 'The name parameter must be of type string, %s given' , is_object ( $ name ) ? get_class ( $ name ) : gettype ( $ name ) ) ) ; } $ definition = $ this -> _definitionManager -> get ...
Build an entry of the container by its name .
11,979
public function addResolver ( $ className , ResolverInterface $ resolver ) { if ( ! class_exists ( $ className ) ) { throw new InvalidArgumentException ( "The cass '{$className} was not found." ) ; } $ this -> _definitionResolvers [ $ className ] = $ resolver ; return $ this ; }
Add a definition resolver to the list of resolvers
11,980
protected function _resolveDefinition ( DefinitionInterface $ definition , array $ parameters = [ ] ) { $ entryName = $ definition -> getName ( ) ; $ definitionResolver = $ this -> _getDefinitionResolver ( $ definition ) ; try { $ value = $ definitionResolver -> resolve ( $ definition , $ parameters ) ; } catch ( \ Exc...
Resolves a definition .
11,981
protected function _getDefinitionResolver ( DefinitionInterface $ definition ) { $ definitionType = get_class ( $ definition ) ; if ( ! isset ( $ this -> _definitionResolvers [ $ definitionType ] ) ) { throw new NotFoundException ( "No definition resolver was configured for definition " . "of type $definitionType" ) ; ...
Returns a resolver capable of handling the given definition .
11,982
public function getMobileSiteType ( ) { $ defaults = $ this -> owner -> stat ( 'defaults' ) ; $ value = $ this -> owner -> getField ( 'MobileSiteType' ) ; if ( ! $ value ) $ value = $ defaults [ 'MobileSiteType' ] ; return $ value ; }
Provide a default if MobileSiteType is not set .
11,983
public function augmentDatabase ( ) { $ defaultThemes = array ( 'blackcandymobile' , 'jquerymobile' ) ; $ currentTheme = $ this -> owner -> getField ( 'MobileTheme' ) ; if ( ! $ currentTheme || in_array ( $ currentTheme , $ defaultThemes ) ) { $ this -> copyDefaultTheme ( $ currentTheme ) ; } }
The default theme is blackcandymobile . If this is still set as a field on SiteConfig then make sure that it s copied into the themes directory from the mobile module .
11,984
public function updateCMSFields ( FieldList $ fields ) { $ fields -> addFieldsToTab ( 'Root.Mobile' , array ( OptionsetField :: create ( 'MobileSiteType' , _t ( 'MobileSiteConfig.MOBILESITEBEHAVIOUR' , 'Mobile site behaviour' ) , $ this -> getMobileSiteTypes ( ) ) , TextField :: create ( 'MobileDomain' , _t ( 'MobileSi...
Append extra fields to the new Mobile tab in the cms .
11,985
public function redirect ( $ url ) { $ location = $ this -> _request -> getBasePath ( ) ; $ location = str_replace ( '//' , '/' , "{$location}/{$url}" ) ; $ this -> _response -> setStatusCode ( 302 ) ; $ header = new GenericHeader ( 'Location' , $ location ) ; $ this -> _response -> getHeaders ( ) -> addHeader ( $ head...
Sends a redirection header and exits execution .
11,986
public function set ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ _key => $ value ) { $ this -> _set ( $ _key , $ value ) ; } return $ this ; } $ this -> _set ( $ key , $ value ) ; return $ this ; }
Sets a value or an array of values to the data that will be rendered .
11,987
protected function _setup ( ) { foreach ( $ this -> _properties as $ property ) { $ element = $ this -> _createElement ( $ property ) ; if ( $ element ) { $ this -> addElement ( $ element [ 'name' ] , $ element ) ; } } $ this -> add ( new Submit ( [ 'value' => 'Save' ] ) ) ; }
Callback for form setup
11,988
public function getSshConnection ( $ multiplex = null ) { $ jumpHost = $ this -> getJumpHost ( ) ; return new Connection ( $ this -> getDefaultUsername ( ) , $ jumpHost ? $ this -> getPrivateIpAddress ( ) : $ this -> getConnectionIp ( ) , $ this -> getPrivateKey ( ) , $ jumpHost , ! is_null ( $ multiplex ) ? $ multiple...
Get SSH connection
11,989
public static function get ( $ file , $ class = 'php' ) { foreach ( self :: $ _paths as $ path ) { $ fileName = "{$path}/{$file}.{$class}" ; if ( is_file ( $ fileName ) ) { $ cfg = new Configuration ( [ 'class' => $ class , 'options' => [ 'file' => $ fileName ] ] ) ; return $ cfg -> initialize ( ) ; } } throw new Excep...
Factory method to search and parse the provided name
11,990
public function initialize ( ) { $ class = $ this -> class ; $ driver = null ; if ( empty ( $ class ) ) { throw new Exception \ InvalidArgumentException ( "The configuration driver is invalid." ) ; } if ( class_exists ( $ class ) ) { $ driver = new $ class ( $ this -> _options ) ; if ( is_a ( $ driver , '\Slick\Configu...
Initializes the driver specified by class using the provided options .
11,991
public static function inspect ( $ str ) { $ result = array ( 'length' => 0 , 'kanji' => 0 , 'hiragana' => 0 , 'katakana' => 0 , ) ; $ result [ 'length' ] = self :: length ( $ str ) ; $ result [ 'kanji' ] = self :: countKanji ( $ str ) ; $ result [ 'hiragana' ] = self :: countHiragana ( $ str ) ; $ result [ 'katakana' ...
Inspects a given string and returns useful details about it .
11,992
public static function countKanji ( $ str , $ extended = false ) { $ matches = array ( ) ; if ( $ extended ) { return preg_match_all ( Helper :: PREG_PATTERN_KANJI_EXTENDED , $ str , $ matches ) ; } else { return preg_match_all ( Helper :: PREG_PATTERN_KANJI , $ str , $ matches ) ; } }
Count number of kanji within the specified string .
11,993
public static function hasKanji ( $ str , $ extended = false ) { if ( $ extended ) { return preg_match ( Helper :: PREG_PATTERN_KANJI_EXTENDED , $ str , $ matches ) > 0 ; } else { return preg_match ( Helper :: PREG_PATTERN_KANJI , $ str , $ matches ) > 0 ; } }
Determines whether the given string contains kanji characters .
11,994
public static function getEntriesFromDatabase ( $ verb ) { if ( ! Analyzer :: hasJapaneseLetters ( $ verb ) ) { $ verb = ( new Transliterator ( ) ) -> transliterate ( $ verb , new System \ Hiragana ( ) ) ; } $ sql = 'SELECT kanji, kana, type FROM verbs WHERE kanji = :kanji OR kana = :kana' ; $ uri = 'sqlite:' . __DIR__...
Gets a verb entries from the database using either Kanji Hiragana or Romaji
11,995
public static function is_tablet ( $ agent = null ) { if ( ! $ agent ) $ agent = $ _SERVER [ 'HTTP_USER_AGENT' ] ; if ( ( preg_match ( '/iP(a|ro)d/i' , $ agent ) ) || ( preg_match ( '/tablet/i' , $ agent ) ) && ( ! preg_match ( '/RX-34/i' , $ agent ) ) || ( preg_match ( '/FOLIO/i' , $ agent ) ) ) { return true ; } else...
Rough detection of tablet user agents based on their user agent string .
11,996
protected function initializeLicenser ( InputInterface $ input , OutputInterface $ output ) { $ license = $ input -> getArgument ( 'license' ) ; try { $ licenseHeader = $ this -> licenseHeaderFactory -> createFromLicenseName ( $ license , [ 'owners' => $ input -> getOption ( 'owners' ) ] ) ; } catch ( \ InvalidArgument...
Initializes the Licenser instance with license information
11,997
public function newCollection ( $ model , $ extClass = null ) { $ this -> modelType = $ model ; if ( $ extClass ) $ this -> category = new $ extClass ; $ this -> category -> setModelType ( $ model ) ; return $ this ; }
create category with model_type
11,998
public function htmlSelectList ( $ attributes = null , $ value = null , $ select = true ) { return $ this -> category -> getOptionListCategories ( $ value , $ attributes , $ select ) ; }
get html select of categories
11,999
public function htmlUlList ( $ attributes = null , $ ul = true ) { return $ this -> category -> getUlListCategories ( $ attributes , $ ul ) ; }
get html ul of categories