idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
239,900
function filter ( callable $ cb ) { $ rowset = clone $ this ; $ rowset -> index = 0 ; $ rowset -> rows = array_filter ( $ this -> rows , $ cb ) ; return $ rowset ; }
Filter by callback
239,901
public function actionIndex ( ) { $ searchModel = new ContactSearch ( ) ; $ dataProvider = $ searchModel -> search ( request ( ) -> queryParams ) ; $ dataProvider -> sort -> defaultOrder = [ 'id' => SORT_DESC ] ; return $ this -> render ( 'index' , [ 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , ]...
Lists all Contact models .
239,902
protected function findModel ( $ id ) { if ( ( $ model = Contact :: findOne ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( t ( 'app' , 'The requested page does not exist.' ) ) ; } }
Finds the Contact model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
239,903
public function insert ( $ data , $ priority = 1 ) { $ priority = ( int ) $ priority ; $ this -> items [ ] = array ( 'data' => $ data , 'priority' => $ priority , ) ; $ this -> getQueue ( ) -> insert ( $ data , $ priority ) ; return $ this ; }
Insert an item into the queue
239,904
protected function getQueue ( ) { if ( null === $ this -> queue ) { $ this -> queue = new $ this -> queueClass ( ) ; if ( ! $ this -> queue instanceof SplPriorityQueue ) { throw new Exception ( sprintf ( 'Queue expects an internal queue of type SplPriorityQueue; received "%s"' , get_class ( $ this -> queue ) ) ) ; } } ...
Get the inner priority queue instance
239,905
static public function setObjectProperties ( $ object , array $ config = [ ] ) { foreach ( static :: createSetterMethods ( $ config ) as $ method => $ value ) { if ( method_exists ( $ object , $ method ) ) { call_user_func_array ( [ $ object , $ method ] , [ $ value ] ) ; } } }
Sets object properties by a given array
239,906
public function validate ( ) { foreach ( $ this -> rules ( ) as $ key => $ value ) { $ this -> rules [ $ key ] = [ $ this -> input ( $ key ) , $ value ] ; } $ validate = $ this -> validator -> validate ( $ this -> rules ) ; if ( $ validate -> fails ( ) ) { if ( $ this -> isAjax ( ) ) { return $ this -> response -> json...
Validate requested form .
239,907
public static function prepararArchivos ( array $ archivos , $ inicio = true ) { $ final = [ ] ; foreach ( $ archivos as $ nombre => $ archivo ) { $ subNombre = $ nombre ; if ( $ inicio ) { $ subNombre = $ archivo [ 'name' ] ; } $ final [ $ nombre ] = $ archivo ; if ( is_array ( $ subNombre ) ) { foreach ( array_keys (...
Prepara el formato en que se presenta los archivos subidos .
239,908
public function wait ( bool $ throwExceptionOnError = true ) : PhoreProcResult { if ( $ this -> proc === null ) $ this -> exec ( ) ; $ buf = null ; if ( $ buf === null ) { $ buf = [ ] ; foreach ( $ this -> listener as $ chanId => $ listener ) { $ buf [ $ chanId ] = "" ; } } while ( true ) { $ allPipesClosed = true ; $ ...
Wait for the process to exit .
239,909
protected static function execute ( ) { try { $ instance = static :: getInstance ( ) ; $ reflectionMethod = new ReflectionMethod ( $ instance , static :: $ method ) ; return $ reflectionMethod -> invokeArgs ( $ instance , static :: $ arguments ) ; } catch ( Exception $ e ) { throw new Exception ( $ e -> getMessage ( ) ...
Execute method of the registered alien
239,910
public static function shouldReceive ( ) { if ( ! isset ( static :: $ mocked [ static :: registerAlien ( ) ] ) ) { static :: $ mocked [ static :: registerAlien ( ) ] = Mockery :: mock ( static :: registerAlien ( ) ) ; } return call_user_func_array ( [ static :: $ mocked [ static :: registerAlien ( ) ] , 'shouldReceive'...
Initiate mock expectation for the registered alien
239,911
private function findMeta ( $ className ) { $ class = new \ ReflectionClass ( $ className ) ; if ( $ class -> implementsInterface ( 'LRezek\\Arachnid\\Proxy\\Entity' ) ) { $ class = $ class -> getParentClass ( ) ; } $ node = $ this -> reader -> getClassAnnotation ( $ class , 'LRezek\\Arachnid\\Annotation\\Node' ) ; $ r...
Does the actual annotation parsing to get meta information for a given class .
239,912
public static function limitByWords ( $ str , $ wordCount = 10 ) { $ words = preg_split ( "/[\s]+/" , $ str , $ wordCount + 1 ) ; $ words = array_slice ( $ words , 0 , $ wordCount ) ; return join ( ' ' , $ words ) ; }
Returns a string limited by the word count specified logic borrowed from StackOverflow
239,913
public function process ( ) { $ em = $ this -> getEm ( ) ; $ cronRegistry = $ this -> getCronjobs ( ) ; $ pending = $ this -> getPending ( ) ; $ scheduleLifetime = $ this -> scheduleLifetime * 60 ; $ now = new \ DateTime ; foreach ( $ pending as $ job ) { $ scheduleTime = $ job -> getScheduleTime ( ) ; if ( $ scheduleT...
run cron jobs
239,914
public function cleanLog ( ) { $ em = $ this -> getEm ( ) ; $ lifetime = array ( Mapper \ Cronjob :: STATUS_SUCCESS => $ this -> getSuccessLogLifetime ( ) * 60 , Mapper \ Cronjob :: STATUS_MISSED => $ this -> getFailureLogLifetime ( ) * 60 , Mapper \ Cronjob :: STATUS_ERROR => $ this -> getFailureLogLifetime ( ) * 60 ,...
delete old cron job logs
239,915
public function tryLockJob ( Entity \ Cronjob $ job ) { $ em = $ this -> getEm ( ) ; $ repo = $ em -> getRepository ( 'AdfabCore\Entity\Cronjob' ) ; if ( $ job -> getStatus ( ) === Mapper \ Cronjob :: STATUS_PENDING ) { $ job -> setStatus ( Mapper \ Cronjob :: STATUS_RUNNING ) ; $ em -> persist ( $ job ) ; $ em -> flus...
try to acquire a lock on a cron job
239,916
public static function matchTime ( $ time , $ expr ) { $ cronExpr = preg_split ( '/\s+/' , $ expr , null , PREG_SPLIT_NO_EMPTY ) ; if ( count ( $ cronExpr ) !== 5 ) { throw new Exception \ InvalidArgumentException ( sprintf ( 'cron expression should have exactly 5 arguments, "%s" given' , $ expr ) ) ; } if ( is_string ...
determine whether a given time falls within the given cron expr
239,917
public function process ( ) { if ( $ this -> _isXhtml === null ) { $ this -> _isXhtml = ( false !== strpos ( $ this -> _html , '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML' ) ) ; } $ this -> _replacementHash = 'MINIFYHTML' . md5 ( $ _SERVER [ 'REQUEST_TIME' ] ) ; $ this -> _placeholders = array ( ) ; $ this -> _html = pre...
Minify the markeup given in the constructor
239,918
public function sql ( $ args ) { list ( $ table_name ) = $ args ; $ rows = Model :: $ list ; if ( ! isset ( $ rows [ $ table_name ] ) ) { \ WP_CLI :: error ( sprintf ( '%s: table is not registered.' , $ table_name ) ) ; } $ model = $ rows [ $ table_name ] ; if ( ! class_exists ( $ model ) ) { \ WP_CLI :: error ( sprint...
Display table schema SQL
239,919
public function tables ( ) { $ table = new \ cli \ Table ( ) ; $ rows = Model :: $ list ; if ( ! $ rows ) { \ WP_CLI :: error ( 'No model is regsitered.' ) ; } $ table -> setHeaders ( [ 'Table Name' , 'Model Class' ] ) ; foreach ( $ rows as $ table_name => $ class ) { $ table -> addRow ( [ $ table_name , $ class ] ) ; ...
Get list of tables which generated by Hametuha \ Pattern \ Model
239,920
public function add ( $ manager ) { if ( ! is_string ( $ manager ) ) { throw new \ InvalidArgumentException ( 'ManagerList::add requires $manager to be a string.' ) ; } $ this -> managerList [ $ manager ] = $ manager ; $ this -> managerStatus [ self :: FLAG_AVAILABLE ] [ $ manager ] = $ manager ; return $ this ; }
Adds a manager dsn to the list .
239,921
public function toPrioritizedArray ( ) { if ( ( $ this -> resetCounter % $ this -> resetAt ) == 0 ) { $ this -> resetAvailableManagers ( ) ; } $ this -> resetCounter ++ ; $ available = & $ this -> managerStatus [ self :: FLAG_AVAILABLE ] ; $ unavailable = & $ this -> managerStatus [ self :: FLAG_UNAVAILABLE ] ; shuffle...
Returns an array or manager dsns sorted by priority .
239,922
protected function resetAvailableManagers ( ) { $ this -> managerStatus [ self :: FLAG_AVAILABLE ] = $ this -> managerList ; $ this -> managerStatus [ self :: FLAG_UNAVAILABLE ] = array ( ) ; }
Makes all managers available .
239,923
public function returnClientErrorResponse ( Zend_Http_Response $ response ) { $ status = $ response -> getStatus ( ) ; switch ( $ status ) { case 401 : $ message = self :: INVALID_API_KEY ; break ; case 403 : $ message = self :: INVALID_STORE_ID ; break ; case 408 : $ message = self :: NETWORK_TIMEOUT ; break ; default...
Return the response data for client errors - 4XX range errors .
239,924
public static function load ( $ path , $ file = '.env' ) { if ( ! is_string ( $ file ) ) { $ file = '.env' ; } $ filePath = rtrim ( $ path , '/' ) . '/' . $ file ; if ( ! is_readable ( $ filePath ) || ! is_file ( $ filePath ) ) { throw new \ InvalidArgumentException ( sprintf ( "Dotenv: Environment file %s not found or...
Load . env file in given directory
239,925
public static function required ( $ environmentVariables , array $ allowedValues = array ( ) ) { $ environmentVariables = ( array ) $ environmentVariables ; $ missingEnvironmentVariables = [ ] ; foreach ( $ environmentVariables as $ environmentVariable ) { $ value = static :: findEnvironmentVariable ( $ environmentVari...
Require specified ENV vars to be present or throw Exception . You can also pass through an set of allowed values for the environment variable .
239,926
protected static function sanitiseVariableValue ( $ value ) { $ value = trim ( $ value ) ; if ( ! $ value ) { return '' ; } if ( strpbrk ( $ value [ 0 ] , '"\'' ) !== false ) { $ quote = $ value [ 0 ] ; $ regexPattern = sprintf ( '/^ %1$s # match a quote at the start of the value ...
Strips quotes from the environment variable value .
239,927
public function handle ( $ old , $ new ) { if ( ! $ this -> canHandle ( $ old ) || ! $ this -> canHandle ( $ new ) ) { return null ; } if ( $ this -> equals ( $ old , $ new ) ) { return false ; } $ this -> lastException = new FailedConstraint ( sprintf ( '%s() body changed' , $ new -> name ) ) ; return true ; }
Check if body of function has changed .
239,928
protected function equals ( $ old , $ new ) { if ( is_array ( $ old ) ) { if ( array_keys ( $ old ) != array_keys ( $ new ) ) { return false ; } foreach ( array_keys ( $ old ) as $ key ) { if ( ! $ this -> equals ( $ old [ $ key ] , $ new [ $ key ] ) ) { return false ; } } return true ; } if ( ! is_object ( $ old ) ) {...
Check if two Node trees are equal .
239,929
final public function logError ( $ msg_code , $ data = array ( ) ) { self :: write ( self :: compileMessage ( self :: $ error_msg [ $ msg_code ] , $ data ) , PEL_ERROR ) ; }
Metodo que permite escribir un log de Error .
239,930
final public function logWarn ( $ msg_code , $ data = array ( ) ) { self :: write ( self :: compileMessage ( self :: $ warn_msg [ $ msg_code ] , $ data ) , PEL_WARNING ) ; }
Metodo que permite escribir un log de Advertencia .
239,931
public function session ( ) { if ( ! ( $ this -> session instanceof Session ) ) { $ this -> session = Session :: singleton ( $ this -> sessionID ) ; } return $ this -> session ; }
Return user session
239,932
public function setSessionData ( ) { $ arr = $ this -> toArray ( ) ; $ arr [ 'login_timestamp' ] = $ this -> loginTimestamp ; $ arr [ 'last_action' ] = $ this -> lastAction ; $ this -> session ( ) -> set ( get_called_class ( ) , serialize ( $ arr ) ) ; }
Set user data in a session
239,933
public function updateLastAction ( ) { $ arr = $ this -> getSessionData ( ) ; $ this -> lastAction = time ( ) ; $ arr [ 'last_action' ] = $ this -> lastAction ; $ this -> session ( ) -> set ( get_called_class ( ) , serialize ( $ arr ) ) ; }
Update the last action time to the current time
239,934
public function initSession ( ) { $ session = $ this -> getSessionData ( ) ; if ( $ this -> checkSession ( $ session ) !== TRUE ) { return $ this -> Logout ( 'invalid_session' ) ; } $ this -> fromSessionData ( ) ; if ( ! $ this -> Read ( ) ) { return $ this -> Logout ( 'user_read_error' ) ; } $ this -> reset ( 'passwor...
Initialise a user session and check it is valid
239,935
public function validSession ( ) { $ session = $ this -> getSessionData ( ) ; if ( $ this -> checkSession ( $ session ) !== TRUE ) { $ this -> loggedIn = FALSE ; return FALSE ; } if ( $ session [ 'active' ] !== $ this -> iget ( 'active' ) || ! $ this -> iget ( 'active' ) ) { $ this -> loggedIn = FALSE ; return FALSE ; ...
Whether the user has a valid session
239,936
public function checkSession ( $ session = FALSE ) { if ( $ session === FALSE ) { $ session = $ this -> getSessionData ( ) ; } if ( ! Parser :: _ak ( $ session , 'id' , FALSE ) ) { return 'no_id' ; } if ( ! Parser :: _ak ( $ session , 'email' , FALSE ) ) { return 'no_email' ; } if ( ! Parser :: _ak ( $ session , 'login...
Check that a session is valid
239,937
public function Logout ( $ reason = FALSE ) { $ this -> loggedIn = FALSE ; $ this -> session ( ) -> Destroy ( ) ; $ this -> _sessionData = FALSE ; $ this -> session ( ) -> Create ( ) ; $ this -> session ( ) -> Refresh ( ) ; if ( $ reason !== FALSE ) { $ this -> session ( ) -> set ( 'requested_url' , $ _SERVER [ 'REQUES...
Logout the user return string Reason
239,938
public static function _Authenticate ( $ email , $ password ) { $ user = static :: _readFromEmail ( $ email ) ; if ( ! $ user ) { return FALSE ; } return $ user -> checkPassword ( $ password ) ; }
Authenticate and attempt to login a user
239,939
public function setValue ( $ value ) { $ this -> value = $ value ; if ( $ value instanceof ValueAwareInterface ) { $ this -> value = $ value -> getFormValue ( ) ; } return $ this ; }
Sets the value or content of the element
239,940
protected function getRenderer ( ) { if ( null === $ this -> renderer ) { $ this -> setRenderer ( new $ this -> rendererClass ( ) ) ; } return $ this -> renderer ; }
Gets the HTML renderer for this element
239,941
public static function getAllGroupCompanies ( $ ccgr_id ) { $ sql = " SELECT ccmp_id, ccmp_name FROM ccxg_company_x_group INNER JOIN ccmp_company ON ccxg_ccmp_id = ccmp_id WHERE ccxg_ccgr_id = :ccgr_...
get all syscomanies array without access control
239,942
public function setLayout ( $ layout = null ) { if ( null !== $ layout && ! is_string ( $ layout ) && ! ( $ layout instanceof ViewModel ) ) { throw new InvalidArgumentException ( 'Invalid value supplied for setLayout.' . 'Expected null, string, or Zend\View\Model\ViewModel.' ) ; } if ( null === $ layout && empty ( $ th...
Set the layout .
239,943
protected function manipulateBody ( $ body , $ mimeType = null ) { if ( $ body instanceof ViewModel ) { $ body = $ this -> viewRenderer -> render ( $ body ) ; $ detectedMimeType = 'text/html' ; } elseif ( null === $ body ) { $ detectedMimeType = 'text/plain' ; $ body = '' ; } if ( null !== ( $ layout = $ this -> getLay...
Manipulate the body based on configuration options .
239,944
protected function renderTextBody ( $ body ) { $ body = html_entity_decode ( trim ( strip_tags ( preg_replace ( '/<(head|title|style|script)[^>]*>.*?<\/\\1>/s' , '' , $ body ) ) ) , ENT_QUOTES ) ; if ( empty ( $ body ) ) { $ body = 'To view this email, open it an email client that supports HTML.' ; } return $ body ; }
Strip html tags and render a text - only version .
239,945
public function compose ( $ body = null , $ mimeType = null ) { if ( null !== $ body && ! is_string ( $ body ) && ! ( $ body instanceof ViewModel ) ) { throw new InvalidArgumentException ( 'Invalid value supplied. Expected null, string or instance of Zend\View\Model\ViewModel.' ) ; } $ body = $ this -> manipulateBody (...
Compose a new message .
239,946
private function generateRoutes ( $ directory ) { $ dirPath = $ directory . 'app/routes/' ; if ( ! file_exists ( $ dirPath ) ) return ; $ iterator = Finder :: create ( ) -> files ( ) -> ignoreDotFiles ( true ) -> sortByName ( ) -> in ( $ dirPath ) ; $ files = iterator_to_array ( $ iterator , true ) ; $ finalContent = '...
Generating final routes file for package
239,947
protected function createInstance ( Connection $ connection , string $ type ) : ConstraintInterface { $ driver = $ connection -> driver ( ) ; if ( ! isset ( $ this -> registry [ $ driver ] [ $ type ] ) ) { throw new \ InvalidArgumentException ( sprintf ( "'%s' constraint is not supported by '%s' driver" ) ) ; } $ class...
Create instance for the given connection
239,948
public function get ( Connection $ connection , string $ type ) : ConstraintInterface { $ driver = $ connection -> driver ( ) ; if ( isset ( $ this -> instances [ $ driver ] [ $ type ] ) ) { return $ this -> instances [ $ driver ] [ $ type ] ; } return $ this -> instances [ $ driver ] [ $ type ] = $ this -> createInsta...
Get constraint type handler for driver
239,949
public function getAll ( Connection $ connection ) : array { foreach ( $ this -> registry as $ types ) { foreach ( array_keys ( $ types ) as $ type ) { $ this -> get ( $ connection , $ type ) ; } } return $ this -> instances [ $ connection -> driver ( ) ] ; }
Get all defined handlers
239,950
public function getHtml128 ( $ string , $ pixelPerByte = 2 , $ height = 30 ) { $ generator = new BarcodeGeneratorHTML ( ) ; return $ generator -> getBarcode ( $ string , BarcodeGeneratorHTML :: TYPE_CODE_128 , $ pixelPerByte , $ height ) ; }
Get HTML as CODE - 128
239,951
public function getHtmlEan13 ( $ string , $ pixelPerByte = 2 , $ height = 30 ) { $ generator = new BarcodeGeneratorHTML ( ) ; return $ generator -> getBarcode ( $ string , BarcodeGeneratorHTML :: TYPE_EAN_13 , $ pixelPerByte , $ height ) ; }
Get HTML as EAN - 13
239,952
public function getHtmlUpcA ( $ string , $ pixelPerByte = 2 , $ height = 30 ) { $ generator = new BarcodeGeneratorHTML ( ) ; return $ generator -> getBarcode ( $ string , BarcodeGeneratorHTML :: TYPE_UPC_A , $ pixelPerByte , $ height ) ; }
Get HTML as UPC
239,953
private function _parseTokenFromRequest ( ) { if ( $ this -> _c_parsedToken ) return $ this -> _c_parsedToken ; $ this -> _c_parsedToken = $ r = $ this -> assertion -> parseTokenStrFromRequest ( new ServerRequestBridgeInPsr ( $ this -> request ( ) ) ) ; return $ r ; }
Parse Token From Request
239,954
public function resolve ( ) { if ( $ this -> sourceFile instanceof UploadedFile ) { $ extension = $ this -> sourceFile -> guessExtension ( ) ; $ name = preg_filter ( '/^php(.+)/' , '$1' , $ this -> sourceFile -> getBasename ( ) ) ; $ this -> originalName = $ this -> sourceFile -> getClientOriginalName ( ) ; } else { $ ...
Override to handle upload before normal creation .
239,955
public function getSqlName ( string $ table , string $ name ) : string { return $ table . '_' . $ this -> getType ( ) . '_' . $ name ; }
Get SQL constraint name
239,956
public function getKeyStr ( $ hash = true ) { $ key = $ this -> key . self :: $ INDEX_SEPERATOR . $ this -> groupId . self :: $ TAG_SEPERATOR . implode ( self :: $ TAG_SEPERATOR , $ this -> gatherTags ( ) ) ; if ( $ hash ) { $ key = md5 ( $ key ) ; } return $ key ; }
calculate composite key
239,957
public function createConfiguration ( $ prefix , $ resourceName , $ resourceClass , array $ templateList , $ eventClass = null , $ parentId = null ) { return new Configuration ( $ prefix , $ resourceName , $ resourceClass , $ templateList , $ eventClass , $ parentId ) ; }
Creates and register a configuration
239,958
public function index ( ) { $ isAppInstalled = $ this -> Installer -> isAppInstalled ( ) ; $ isAppReadyInstall = $ this -> InstallerCheck -> isAppReadyToInstall ( ) ; $ phpVesion = $ this -> InstallerCheck -> checkPhpVersion ( ) ; $ phpModules = $ this -> InstallerCheck -> checkPhpExtensions ( ) ; $ filesWritable = $ t...
Action index . Used to view state of installation for application .
239,959
public function getUserFromToken ( $ token ) { $ expiration = U :: unixToDb ( time ( ) - UserLink :: $ forgotLinkTimeframe ) ; $ link = UserLink :: where ( 'link' , $ token ) -> where ( 'type' , UserLink :: FORGOT_PASSWORD ) -> where ( 'created_at' , $ expiration , '>' ) -> first ( ) ; if ( ! $ link ) { throw new AuthE...
Looks up a user from a given forgot token .
239,960
public function buildLink ( $ userId , $ ip , $ userAgent ) { $ link = new UserLink ( ) ; $ link -> user_id = $ userId ; $ link -> type = UserLink :: FORGOT_PASSWORD ; try { $ link -> save ( ) ; } catch ( \ Exception $ e ) { throw new \ Exception ( "Could not create reset password link for user # $userId: " . $ e -> ge...
Builds a reset password link .
239,961
public static function fetchArguments ( $ _class = null , $ _method = null , $ args = null ) { if ( empty ( $ _class ) || empty ( $ _method ) ) { return null ; } $ args_def = array ( ) ; if ( ! empty ( $ args ) ) { $ analyze = new ReflectionMethod ( $ _class , $ _method ) ; foreach ( $ analyze -> getParameters ( ) as $...
Launch a class s method fetching arguments
239,962
public static function generateList ( $ region = DateTimeZone :: ALL ) { $ regions = array ( DateTimeZone :: AFRICA , DateTimeZone :: AMERICA , DateTimeZone :: ANTARCTICA , DateTimeZone :: ASIA , DateTimeZone :: ATLANTIC , DateTimeZone :: AUSTRALIA , DateTimeZone :: EUROPE , DateTimeZone :: INDIAN , DateTimeZone :: PAC...
Generate Time Zone List .
239,963
public function render ( $ context = [ ] ) { if ( $ this -> getElement ( ) -> hasAttribute ( 'value' ) ) { $ this -> getElement ( ) -> getAttributes ( ) -> remove ( 'value' ) ; } return parent :: render ( $ context ) ; }
Overrides to remove the unnecessary value attribute
239,964
public function clearType ( $ typeKey ) { if ( isset ( $ this -> models [ $ typeKey ] ) ) { unset ( $ this -> models [ $ typeKey ] ) ; } return $ this ; }
Clears all models in the memory cache for a specific type .
239,965
public function push ( Model $ model ) { $ this -> models [ $ model -> getType ( ) ] [ $ model -> getId ( ) ] = $ model ; return $ this ; }
Pushes a model into the memory cache .
239,966
public function remove ( $ typeKey , $ identifier ) { if ( isset ( $ this -> models [ $ typeKey ] [ $ identifier ] ) ) { unset ( $ this -> models [ $ typeKey ] [ $ identifier ] ) ; } return $ this ; }
Removes a model from the memory cache based on type and identifier .
239,967
public function get ( $ typeKey , $ identifier ) { $ map = $ this -> getAllForType ( $ typeKey ) ; if ( isset ( $ map [ $ identifier ] ) ) { return $ map [ $ identifier ] ; } return null ; }
Gets a model from the memory cache based on type and identifier .
239,968
public function createContent ( Location $ location = null , Campaign $ campaign = null ) { $ connection = $ this -> getRestApiConnectionByLocation ( $ location ) ; $ remoteContentTypes = $ connection -> getContentTypes ( ) ; foreach ( $ remoteContentTypes as $ remoteContentType ) { $ id = $ location -> getId ( ) . '-'...
When a new Activity is being created this handler method will be called to retrieve a new Content object for the Activity .
239,969
public function setPadding ( $ padding = 0 ) { $ padding = $ this -> parseSizes ( $ padding ) ; foreach ( $ padding as $ side => $ value ) { if ( ! is_int ( $ value ) || $ value < 0 ) { throw new InvalidArgumentException ( sprintf ( 'Invalid %s padding: "%s". Must be a positive integer value.' , $ side , $ value ) ) ; ...
Sets style padding .
239,970
public function setMargin ( $ margin = 0 ) { $ margin = $ this -> parseSizes ( $ margin ) ; foreach ( $ margin as $ side => $ value ) { if ( ! is_int ( $ value ) || $ value < 0 ) { throw new InvalidArgumentException ( sprintf ( 'Invalid %s margin: "%s". Must be a positive integer value.' , $ side , $ value ) ) ; } $ th...
Sets style margin .
239,971
public static function quickValidate ( ? string $ value , array $ constraints = [ ] ) { $ validator = new static ( 'quickValidate function' , InputFieldTypes :: PASSED , [ ] , $ value , null ) ; if ( is_array ( $ constraints ) && count ( $ constraints ) > 0 ) { foreach ( $ constraints as $ constraint ) { if ( is_array ...
Validates input as a one - off . Allows quick and dirty validation . Returns null if the value is not valid .
239,972
public function addConstraint ( Constraint $ constraint ) : void { $ constraint -> setValidator ( $ this ) ; array_push ( $ this -> constraints , $ constraint ) ; }
Add a constraint to the validator
239,973
public function reportError ( string $ error_message ) : void { $ error_message = sprintf ( $ error_message , $ this -> field_name ) ; if ( null != $ this -> validation_set ) { $ this -> validation_set -> addValidationError ( new ValidationError ( $ this -> field_name , $ error_message ) ) ; } }
Report the error message to validation set
239,974
public function validate ( ) : void { $ this -> value = null ; $ value = $ this -> filter ( $ this -> raw_value ) ; if ( true === $ this -> checkValidity ( $ value ) ) { $ this -> is_valid = true ; } else { $ this -> is_valid = false ; $ this -> reportError ( $ this -> error_message ) ; $ error_message = sprintf ( $ th...
Do the validation . This process starts by filtering the value then checks the validity and finally checks the constraints .
239,975
public function getAssignments ( $ userId ) { if ( empty ( $ userId ) ) { return [ ] ; } $ roles = $ this -> allRoleNamesByUserId ( $ userId ) ; return AssignmentHelper :: forge ( $ userId , $ roles ) ; }
Returns all role assignment information for the specified user .
239,976
public function revoke ( $ role , $ userId ) { $ userId = $ this -> getId ( $ userId ) ; $ entity = \ App :: $ domain -> account -> login -> oneById ( $ userId ) ; $ this -> model -> deleteAll ( [ 'user_id' => $ userId , 'item_name' => $ role ] ) ; }
Revokes a role from a user .
239,977
private function getPageMap ( string $ sourceLanguage , string $ targetLanguage ) : PageMap { if ( ! array_key_exists ( $ key = $ sourceLanguage . '->' . $ targetLanguage , $ this -> pageMaps ) ) { return $ this -> pageMaps [ $ key ] = new PageMap ( $ sourceLanguage , $ targetLanguage , $ this -> database , $ this -> l...
Retrieve pageMap .
239,978
private function getArticleMap ( string $ sourceLanguage , string $ targetLanguage ) : ArticleMap { if ( ! array_key_exists ( $ key = $ sourceLanguage . '->' . $ targetLanguage , $ this -> articleMaps ) ) { return $ this -> articleMaps [ $ key ] = new ArticleMap ( $ this -> getPageMap ( $ sourceLanguage , $ targetLangu...
Retrieve article map .
239,979
private function getArticleContentMap ( string $ sourceLanguage , string $ targetLanguage ) : ArticleContentMap { if ( ! array_key_exists ( $ key = $ sourceLanguage . '->' . $ targetLanguage , $ this -> articleContentMaps ) ) { return $ this -> articleContentMaps [ $ key ] = new ArticleContentMap ( $ this -> getArticle...
Retrieve article content map .
239,980
public function getValue ( ) { $ terms = $ this -> base [ 'value' ] ; if ( is_array ( $ terms ) ) { $ ret = array ( ) ; foreach ( $ terms as $ t ) { $ ret [ ] = $ this -> termFactory -> create ( $ t , $ this -> taxonomy ( ) ) ; } return $ ret ; } elseif ( is_object ( $ terms ) ) { return $ this -> termFactory -> create...
Get Term or array of Terms .
239,981
public function taxonomy ( ) { if ( $ this -> _taxonomy === null ) { $ this -> _taxonomy = $ this -> taxonomyFactory -> create ( $ this -> base [ 'taxonomy' ] ) ; } return $ this -> _taxonomy ; }
Get Term Taxonomy .
239,982
final public function getWriteMode ( ) { switch ( $ this -> getDataMode ( ) ) { case Configuration :: DATA_MODE_WIPE : case Configuration :: DATA_MODE_PROGRESSIVE : $ this -> setWriteMode ( static :: WRITE_MODE_INSERT ) ; break ; default : $ this -> setWriteMode ( static :: WRITE_MODE_UPSERT ) ; } return $ this -> writ...
Returns the current write mode
239,983
final public function batchUpdate ( $ scn , array $ criteria , array $ update ) { return $ this -> getCollectionForModel ( $ scn ) -> update ( $ criteria , $ update , [ 'multiple' => true ] ) ; }
Performs a batch update
239,984
final protected function doUpsert ( $ scn , array $ kvs ) { $ upsertKey = isset ( $ kvs [ 'external' ] ) ? 'external' : 'legacy' ; $ upsertNs = 'legacy' === $ upsertKey ? 'source' : 'namespace' ; $ upsertId = 'legacy' === $ upsertKey ? 'id' : 'identifier' ; $ update = [ '$set' => $ kvs ] ; if ( ! isset ( $ kvs [ $ upse...
Handles a single document upsert
239,985
final protected function setWriteMode ( $ mode ) { if ( ! in_array ( $ mode , [ static :: WRITE_MODE_INSERT , static :: WRITE_MODE_UPSERT , static :: WRITE_MODE_UPDATE ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Passed write mode "%s" is invalid!' , $ mode ) ) ; } $ this -> writeMode = $ mode ; }
Sets the current write mode
239,986
public function onKernelController ( FilterControllerEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ route = $ this -> routes -> get ( $ request -> attributes -> get ( '_route' ) ) ; if ( $ route && $ route -> hasContent ( ) ) { $ this -> populateContent ( $ route , $ request ) ; } }
Handler Kernel Controller events
239,987
public function fields ( $ value = null ) { if ( null === $ value ) { return $ this -> fields ; } $ this -> fields = $ value ; return $ this ; }
Fields getter and setter .
239,988
public function field ( string $ name , Syntax $ value = null ) { if ( $ value === null ) { $ names = explode ( '.' , $ name ) ; $ syntax = $ this ; foreach ( $ names as $ field ) { while ( method_exists ( $ syntax , 'syntax' ) ) { $ syntax = $ syntax -> syntax ( ) ; } if ( $ syntax instanceof ObjectSyntax && array_key...
Setter and getter of a specific field .
239,989
protected function clearValues ( ) { $ this -> values = [ ] ; foreach ( $ this -> fields as $ name => $ syntax ) { $ this -> values [ $ name ] = ( object ) [ 'value' => null , 'error' => static :: MISSING_FIELD ] ; } }
Clears the parsed values .
239,990
public function dump ( $ value ) : string { $ value = ( array ) $ value ; $ result = [ ] ; $ current = '' ; $ missingField = false ; try { foreach ( $ this -> fields as $ name => $ syntax ) { $ current = $ name ; if ( ! array_key_exists ( $ name , $ value ) ) { $ missingField = true ; break ; } $ result [ ] = $ syntax ...
Transforms an object to a string based on the fields or throws a DumpException .
239,991
public function setOptions ( $ options ) { if ( ! is_array ( $ options ) && ! $ options instanceof \ Traversable ) { throw new \ InvalidArgumentException ( sprintf ( 'Parameter provided to %s must be an array or Traversable' , __METHOD__ ) ) ; } foreach ( $ options as $ key => $ value ) { $ this -> setOption ( $ key , ...
Set service options from array or traversable object
239,992
public function getOptions ( ) { if ( ! $ this -> options ) { if ( isset ( $ this -> optionsClass ) ) { $ this -> options = new $ this -> optionsClass ( array ( ) ) ; } else { $ this -> options = new Options ( array ( ) ) ; } } return $ this -> options ; }
Retrieve service options
239,993
public function getOption ( $ key , $ default = null ) { if ( $ this -> hasOption ( $ key ) ) { return $ this -> getOptions ( ) -> __get ( $ key ) ; } return $ default ; }
Retrieve a single option
239,994
public function setConfig ( $ config ) { if ( is_string ( $ config ) ) { if ( file_exists ( $ config ) ) { $ config = \ Zend \ Config \ Factory :: fromFile ( $ config ) ; } else { throw new \ InvalidArgumentException ( sprintf ( 'Unable to read configurations from file %s' , $ config ) ) ; } } if ( ! is_array ( $ confi...
Set options as config file array or traversable object
239,995
protected function normalize_path ( $ path ) { $ path = str_replace ( '\\' , '/' , $ path ) ; $ path = preg_replace ( '|/+|' , '/' , $ path ) ; return rtrim ( $ path , '/' ) ; }
Normalize a path .
239,996
protected function get_file ( $ file ) { $ path_parts = $ this -> parse_path ( $ file ) ; if ( '' === $ path_parts [ 0 ] ) { $ file = $ this -> root ; unset ( $ path_parts [ 0 ] ) ; } else { $ file = $ this -> cwd ; } foreach ( $ path_parts as $ part ) { if ( '' === $ part ) { continue ; } if ( 'dir' !== $ file -> type...
Get the data for a file .
239,997
protected function get_default_atts ( $ atts ) { if ( false === isset ( $ atts [ 'type' ] ) ) { $ atts [ 'type' ] = 'file' ; } if ( 'file' === $ atts [ 'type' ] ) { $ defaults = array ( 'contents' => '' , 'mode' => 0644 , 'size' => 0 , ) ; } elseif ( 'dir' === $ atts [ 'type' ] ) { $ defaults = array ( 'contents' => ne...
Get the default attributes for a file .
239,998
public function add_file ( $ file , array $ atts = array ( ) ) { $ parent = $ this -> get_file ( dirname ( $ file ) ) ; $ filename = basename ( $ file ) ; if ( false === $ parent || true === isset ( $ parent -> contents -> $ filename ) ) { return false ; } $ parent -> contents -> $ filename = $ this -> get_default_atts...
Create a file or directory .
239,999
public function mkdir_p ( $ file , array $ atts = array ( ) ) { $ dir_levels = $ this -> parse_path ( $ file ) ; $ path = '' ; $ atts [ 'type' ] = 'dir' ; foreach ( $ dir_levels as $ level ) { $ path .= '/' . $ level ; if ( $ this -> exists ( $ path ) ) { continue ; } if ( ! $ this -> add_file ( $ path , $ atts ) ) { r...
Create a deep directory .