idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
500 | public function set ( $ key , $ value = null , $ filter = null ) { is_null ( $ filter ) and $ filter = $ this -> _auto_filter ; $ this -> _view -> set ( $ key , $ value , $ filter ) ; return $ this ; } | Sets a variable on the template |
501 | public function auto_filter ( $ setting = null ) { if ( func_num_args ( ) == 0 ) { return $ this -> _view -> auto_filter ( ) ; } return $ this -> _view -> auto_filter ( $ setting ) ; } | Change auto filter setting |
502 | public function banAction ( ) { $ params = $ this -> params ( ) ; $ locator = $ this -> getServiceLocator ( ) ; $ model = $ locator -> get ( 'Grid\User\Model\User\Model' ) ; $ user = $ model -> find ( $ params -> fromRoute ( 'id' ) ) ; if ( empty ( $ user ) ) { $ this -> getResponse ( ) -> setStatusCode ( 404 ) ; return ; } if ( ! $ this -> getPermissionsModel ( ) -> isAllowed ( $ user , 'ban' ) ) { $ this -> getResponse ( ) -> setStatusCode ( 403 ) ; return ; } if ( $ user -> ban ( ) ) { $ this -> messenger ( ) -> add ( 'user.action.ban.success' , 'user' , Message :: LEVEL_INFO ) ; } else { $ this -> messenger ( ) -> add ( 'user.action.ban.failed' , 'user' , Message :: LEVEL_ERROR ) ; } return $ this -> redirect ( ) -> toRoute ( 'Grid\User\Admin\List' , array ( 'locale' => ( string ) $ this -> locale ( ) , ) ) ; } | Ban a user |
503 | protected function getUserModel ( ) { if ( null === $ this -> userModel ) { $ this -> userModel = $ this -> getServiceLocator ( ) -> get ( 'Grid\User\Model\User\Model' ) ; } return $ this -> userModel ; } | Get user model |
504 | public function getIdentity ( ) { $ identity = parent :: getIdentity ( ) ; if ( null !== $ identity && ! $ this -> identityRefreshed ) { $ user = $ this -> getUserModel ( ) -> find ( $ identity -> id ) ; if ( ! empty ( $ user ) ) { $ this -> getStorage ( ) -> write ( $ identity = $ user ) ; $ this -> identityRefreshed = true ; } } return $ identity ; } | Returns the identity from storage or null if no identity is available |
505 | public static function getAll ( $ mapping ) { $ mappingsArray = array ( ) ; foreach ( $ mapping as $ mappedEntity ) { $ instance = new Mapper ( ) ; self :: populateInstance ( $ instance , $ mappedEntity ) ; $ mappingsArray [ ] = $ instance ; } return $ mappingsArray ; } | Get an array of all mappers . |
506 | private function getRandomChoice ( CustomField $ field ) { $ choices = $ field -> getOptions ( ) [ 'choices' ] ; $ multiple = $ field -> getOptions ( ) [ 'multiple' ] ; $ other = $ field -> getOptions ( ) [ 'other' ] ; if ( $ other ) { $ choices [ ] = array ( 'slug' => '_other' ) ; } $ picked = array ( ) ; if ( $ multiple ) { $ numberSelected = rand ( 1 , count ( $ choices ) - 1 ) ; for ( $ i = 0 ; $ i < $ numberSelected ; $ i ++ ) { $ picked [ ] = $ this -> pickChoice ( $ choices ) ; } if ( $ other ) { $ result = array ( "_other" => NULL , "_choices" => $ picked ) ; if ( in_array ( '_other' , $ picked ) ) { $ result [ '_other' ] = $ this -> faker -> realText ( 70 ) ; } return $ result ; } } else { $ picked = $ this -> pickChoice ( $ choices ) ; if ( $ other ) { $ result = array ( '_other' => NULL , '_choices' => $ picked ) ; if ( $ picked === '_other' ) { $ result [ '_other' ] = $ this -> faker -> realText ( 70 ) ; } return $ result ; } } } | pick a random choice |
507 | public static function saveMany ( $ datasets ) { $ models = [ ] ; if ( ! is_array ( $ datasets ) ) { $ datasets = [ $ datasets ] ; } foreach ( $ datasets as $ dataset ) { $ class = get_called_class ( ) ; $ model = new $ class ( ) ; foreach ( $ dataset as $ attribute => $ value ) { $ model -> { $ attribute } = $ value ; } $ model -> save ( ) ; $ models [ ] = $ model ; } return collect ( $ models ) ; } | Saves many Models . |
508 | public function getVersions ( ) { $ record = $ this -> getRecord ( ) ; $ return = ArrayList :: create ( ) ; if ( $ record -> hasExtension ( Versioned :: class ) ) { $ versions = $ record -> AllVersions ( ) ; foreach ( $ versions as $ version ) { $ i = $ version -> Version ; $ diff = null ; if ( $ i > 1 ) { $ frm = Versioned :: get_version ( $ record -> ClassName , $ record -> ID , $ i - 1 ) ; $ to = Versioned :: get_version ( $ record -> ClassName , $ record -> ID , $ i ) ; if ( $ frm && $ to ) { $ diff = DataDifferencer :: create ( $ frm , $ to ) ; $ diff -> ignoreFields ( [ "LastEdited" ] ) ; } } $ return -> add ( ArrayData :: create ( [ "Version" => $ version , "Diff" => $ diff ] ) ) ; } } $ this -> extend ( "updateVersions" , $ versions ) ; return $ return ; } | Get a list of versions of the current record . |
509 | private function buildInternal ( array $ arguments ) { $ builder = ProcessBuilder :: create ( $ this -> config -> getPhpCliBinary ( ) ) ; if ( null !== ( $ cliArguments = $ this -> config -> getPhpCliArguments ( ) ) ) { $ builder -> addArguments ( $ cliArguments ) ; } $ builder -> addArguments ( $ arguments ) ; if ( null !== ( $ environment = $ this -> config -> getPhpCliEnvironment ( ) ) ) { foreach ( $ environment as $ name => $ value ) { $ builder -> setEnv ( $ name , $ value ) ; } } $ builder -> setEnv ( 'COMPOSER' , $ this -> homePath . DIRECTORY_SEPARATOR . 'composer.json' ) ; return $ builder ; } | Build the internal process builder . |
510 | public function prepareSearchParam ( ) { if ( isset ( $ this -> request [ 'searchFields' ] ) and ! empty ( $ this -> request [ 'searchFields' ] ) ) { $ returnSearch = Array ( ) ; $ countSearchFields = 0 ; foreach ( $ this -> request [ 'searchFields' ] as $ key => $ value ) { $ returnSearch [ $ countSearchFields ] [ 'indexColumn' ] = $ key ; $ returnSearch [ $ countSearchFields ] [ 'valueColumn' ] = $ value ; $ countSearchFields ++ ; } return $ returnSearch ; } else { return null ; } } | Prepara valores e colunas de filtro |
511 | private function prepareSearchStatus ( $ valueColumn , $ getParamsFieldGrid , $ columNamesSearchSort ) { $ valuesTranslate = explode ( "," , $ this -> translate -> translate ( $ columNamesSearchSort . '_values' ) ) ; $ valuesTranslateFlip = array_flip ( $ valuesTranslate ) ; $ valuesIni = explode ( "," , $ getParamsFieldGrid [ $ columNamesSearchSort ] [ 'values' ] ) ; return ( isset ( $ valuesIni [ $ valuesTranslateFlip [ $ valueColumn ] ] ) and ! empty ( $ valuesIni [ $ valuesTranslateFlip [ $ valueColumn ] ] ) ) ? $ valuesIni [ $ valuesTranslateFlip [ $ valueColumn ] ] : null ; } | Prepara o valor de busca para coluna do tipo Status |
512 | protected function prepareOptions ( ) { $ options = [ ] ; foreach ( $ this -> getSelectOptions ( ) as $ value => $ label ) { $ value = addslashes ( $ value ) ; $ label = addslashes ( $ label ) ; $ options [ ] = [ 'sValue' => $ value , 'sLabel' => $ label , ] ; } return $ options ; } | Formats field options as javascript |
513 | public function add ( $ key , $ message ) { $ fullKey = static :: SESSION_NAME . '.' . $ key ; $ base = Base :: instance ( ) ; if ( $ base -> exists ( $ fullKey ) ) { $ base -> push ( $ fullKey , $ message ) ; } else { $ base -> set ( $ fullKey , [ $ message ] ) ; } return $ this ; } | Add message to flash message |
514 | public function get ( $ key ) { $ fullKey = static :: SESSION_NAME . '.' . $ key ; $ base = Base :: instance ( ) ; $ message = $ base -> get ( $ fullKey ) ; $ base -> clear ( $ fullKey ) ; return $ message ; } | Get message from flash message |
515 | public function all ( ) { $ base = Base :: instance ( ) ; $ messages = $ base -> get ( static :: SESSION_NAME ) ; $ base -> clear ( static :: SESSION_NAME ) ; return $ messages ; } | Get all message |
516 | private function executeRead ( $ statement , array $ parameters ) { if ( $ this -> transactionCount == 0 ) { $ connection = $ this -> pool -> selectReadConnection ( ) ; } else { $ connection = $ this -> transactionConnection ; } try { return $ connection -> execute ( $ this -> expandPlaceholders ( $ statement , $ parameters ) , $ parameters ) ; } catch ( ConnectionException $ e ) { $ this -> pool -> disableReadConnection ( $ connection ) ; if ( $ this -> pool -> getReadConnectionCount ( ) == 0 ) { throw $ e ; } return $ this -> executeRead ( $ statement , $ parameters ) ; } } | Executes a statement using a read connection from the pool . |
517 | private function executeWrite ( $ statement , array $ parameters ) { if ( $ this -> transactionCount == 0 ) { $ connection = $ this -> pool -> selectWriteConnection ( ) ; } else { $ connection = $ this -> transactionConnection ; } try { return $ connection -> execute ( $ this -> expandPlaceholders ( $ statement , $ parameters ) , $ parameters ) ; } catch ( ConnectionException $ e ) { $ this -> pool -> disableWriteConnection ( $ connection ) ; if ( $ this -> pool -> getWriteConnectionCount ( ) == 0 ) { throw $ e ; } return $ this -> executeWrite ( $ statement , $ parameters ) ; } } | Executes a statement using a write connection from the pool . |
518 | private function expandPlaceholders ( $ statement , array $ parameters ) { $ index = 0 ; return preg_replace_callback ( '/[\.]{3}\?|\?/' , function ( $ match ) use ( & $ index , & $ statement , & $ parameters ) { if ( $ match [ 0 ] != '...?' ) { ++ $ index ; return $ match [ 0 ] ; } if ( ! is_array ( $ parameters [ $ index ] ) || count ( $ parameters [ $ index ] ) == 0 ) { throw new OperationException ( sprintf ( 'Variable length parameter %d is not an array.' , $ index ) , $ statement ) ; } $ result = implode ( ',' , array_fill ( 0 , count ( $ parameters [ $ index ] ) , '?' ) ) ; ++ $ index ; return $ result ; } , $ statement ) ; } | Replaces variable length placeholders with the real number of placeholder . |
519 | public function childelementtypesAction ( Request $ request ) { $ eid = $ request -> get ( 'eid' ) ; $ elementService = $ this -> get ( 'phlexible_element.element_service' ) ; $ iconResolver = $ this -> get ( 'phlexible_element.icon_resolver' ) ; $ element = $ elementService -> findElement ( $ eid ) ; $ elementtype = $ elementService -> findElementtype ( $ element ) ; $ childElementtypes = $ elementService -> findAllowedChildren ( $ elementtype ) ; $ data = [ ] ; foreach ( $ childElementtypes as $ childElementtype ) { if ( ! in_array ( $ childElementtype -> getType ( ) , [ Elementtype :: TYPE_FULL , Elementtype :: TYPE_STRUCTURE ] ) ) { continue ; } $ data [ $ childElementtype -> getTitle ( ) . '_' . $ childElementtype -> getId ( ) ] = [ 'id' => $ childElementtype -> getId ( ) , 'title' => $ childElementtype -> getTitle ( ) , 'icon' => $ iconResolver -> resolveElementtype ( $ childElementtype ) , 'type' => $ childElementtype -> getType ( ) , ] ; } ksort ( $ data ) ; $ data = array_values ( $ data ) ; return new JsonResponse ( [ 'elementtypes' => $ data ] ) ; } | List all element types . |
520 | public function copyAction ( Request $ request ) { $ parentId = $ request -> get ( 'id' ) ; $ sourceId = $ request -> get ( 'for_tree_id' ) ; $ prevId = $ request -> get ( 'prev_id' ) ; $ elementService = $ this -> get ( 'phlexible_element.element_service' ) ; $ treeManager = $ this -> get ( 'phlexible_tree.tree_manager' ) ; $ sourceTree = $ treeManager -> getByNodeId ( $ sourceId ) ; $ sourceNode = $ sourceTree -> get ( $ sourceId ) ; $ targetTree = $ treeManager -> getByNodeId ( $ parentId ) ; $ parentNode = $ targetTree -> get ( $ parentId ) ; $ prevNode = $ targetTree -> get ( $ prevId ) ; $ sourceElement = $ elementService -> findElement ( $ sourceNode -> getTypeId ( ) ) ; $ sourceElementVersion = $ elementService -> findLatestElementVersion ( $ sourceElement ) ; $ sourceStructure = $ elementService -> findElementStructure ( $ sourceElementVersion ) ; $ targetElement = $ elementService -> createElement ( $ sourceElementVersion -> getElementSource ( ) , $ sourceElement -> getMasterLanguage ( ) , $ this -> getUser ( ) -> getId ( ) ) ; $ targetNode = $ targetTree -> create ( $ parentNode , $ prevNode , $ sourceNode -> getType ( ) , $ targetElement -> getEid ( ) , $ sourceNode -> getAttributes ( ) , $ this -> getUser ( ) -> getId ( ) , $ sourceNode -> getSortMode ( ) , $ sourceNode -> getSortDir ( ) , $ sourceNode -> getInNavigation ( ) ) ; $ targetStructure = clone $ sourceStructure ; $ targetStructure -> setId ( null ) ; $ targetStructure -> setDataId ( UuidUtil :: generate ( ) ) ; $ rii = new \ RecursiveIteratorIterator ( new ElementStructureIterator ( $ targetStructure -> getStructures ( ) ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ rii as $ structure ) { $ structure -> setId ( null ) ; $ structure -> setDataId ( UuidUtil :: generate ( ) ) ; } $ targetElementVersion = $ elementService -> createElementVersion ( $ targetElement , $ targetStructure , null , $ this -> getUser ( ) -> getId ( ) ) ; return new ResultResponse ( true , 'Element copied.' , [ 'id' => $ targetNode -> getId ( ) ] ) ; } | Copy an Element . |
521 | public function moveAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ targetId = $ request -> get ( 'target' ) ; $ treeManager = $ this -> get ( 'phlexible_tree.tree_manager' ) ; $ tree = $ treeManager -> getByNodeId ( $ id ) ; $ node = $ tree -> get ( $ id ) ; $ targetTree = $ treeManager -> getByNodeId ( $ targetId ) ; $ targetNode = $ tree -> get ( $ targetId ) ; if ( $ id === $ targetId ) { return new ResultResponse ( false , 'source_id === target_id' ) ; } $ tree -> move ( $ node , $ targetNode , $ this -> getUser ( ) -> getId ( ) ) ; return new ResultResponse ( true , 'Element moved.' , [ 'id' => $ id , 'parent_id' => $ targetId ] ) ; } | Move an Element . |
522 | public function checkDeleteAction ( Request $ request ) { $ treeId = $ request -> get ( 'id' ) ; $ language = $ request -> get ( 'language' , 'de' ) ; $ treeManager = $ this -> get ( 'phlexible_tree.tree_manager' ) ; $ treeMeditator = $ this -> get ( 'phlexible_tree.mediator' ) ; $ siterootManager = $ this -> get ( 'phlexible_siteroot.siteroot_manager' ) ; $ nodeId = $ treeId [ 0 ] ; $ tree = $ treeManager -> getByNodeId ( $ nodeId ) ; $ node = $ tree -> get ( $ nodeId ) ; $ instances = $ treeManager -> getInstanceNodes ( $ node ) ; if ( count ( $ instances ) > 1 ) { $ instancesArray = [ ] ; foreach ( $ instances as $ instanceNode ) { $ siteroot = $ siterootManager -> find ( $ instanceNode -> getTree ( ) -> getSiterootId ( ) ) ; $ instanceTitle = $ treeMeditator -> getField ( $ instanceNode , 'backend' , $ language ) ; $ instancesArray [ ] = [ $ instanceNode -> getId ( ) , $ siteroot -> getTitle ( ) , $ instanceTitle , $ instanceNode -> getCreatedAt ( ) -> format ( 'Y-m-d H:i:s' ) , ( bool ) $ instanceNode -> getTree ( ) -> isInstanceMaster ( $ instanceNode ) , ( bool ) ( $ instanceNode -> getId ( ) === $ nodeId ) , ] ; } return new ResultResponse ( true , '' , $ instancesArray ) ; } return new ResultResponse ( true , '' , [ ] ) ; } | predelete action check if element has instances . |
523 | public function deleteAction ( Request $ request ) { $ treeIds = $ request -> get ( 'id' ) ; if ( ! is_array ( $ treeIds ) ) { $ treeIds = [ $ treeIds ] ; } $ treeManager = $ this -> get ( 'phlexible_tree.tree_manager' ) ; foreach ( $ treeIds as $ treeId ) { $ tree = $ treeManager -> getByNodeId ( $ treeId ) ; $ node = $ tree -> get ( $ treeId ) ; $ tree -> delete ( $ node , $ this -> getUser ( ) -> getId ( ) ) ; } return new ResultResponse ( true , 'Item(s) deleted' ) ; } | Delete an Element . |
524 | public function checkStatus ( ) { if ( array_key_exists ( '_status' , $ this -> attributes ) && $ this -> attributes [ '_status' ] == 'new' ) { $ this -> attributes [ '_status' ] = 'old' ; return ; } $ this -> attributes = array ( ) ; $ this -> clear ( ) ; } | Metodo llamado en Kodazzi \ boostrap . php para verificar el estatus de la bolsa . |
525 | public function listJsonAction ( Request $ request ) { $ totalEntities = $ this -> countTotal ( ) ; $ offset = intval ( $ request -> get ( 'iDisplayStart' ) ) ; $ limit = intval ( $ request -> get ( 'iDisplayLength' ) ) ; $ sortColumn = intval ( $ request -> get ( 'iSortCol_0' ) ) ; $ sortDirection = $ request -> get ( 'sSortDir_0' ) ; $ search = $ request -> get ( 'sSearch' ) ; $ echo = intval ( $ request -> get ( 'sEcho' ) ) ; $ entities = $ this -> findAllForDataTables ( $ search , $ sortColumn , $ sortDirection , null , $ request -> getLocale ( ) ) ; $ totalFilteredEntities = count ( $ entities -> getScalarResult ( ) ) ; $ entities -> setFirstResult ( $ offset ) -> setMaxResults ( $ limit ) ; $ data = $ entities -> getResult ( ) ; $ response = array ( 'iTotalRecords' => $ totalEntities , 'iTotalDisplayRecords' => $ totalFilteredEntities , 'sEcho' => $ echo , 'aaData' => $ data ) ; return new JsonResponse ( $ response ) ; } | Lists all translation entities . |
526 | public function newAction ( Request $ request ) { $ entity = new Translation ( ) ; $ form = $ this -> createForm ( 'CoreBundle\Form\TranslationType' , $ entity ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ this -> updateTranslation ( $ entity ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'translation.created' ) ; return $ this -> redirectToRoute ( 'core_translation_index' ) ; } return $ this -> render ( 'CoreBundle:Translation:new.html.twig' , array ( 'translation' => $ entity , 'form' => $ form -> createView ( ) , ) ) ; } | Creates a new translation entity . |
527 | public function showAction ( Request $ request , $ key , $ domain ) { $ deleteForm = $ this -> createDeleteForm ( $ key , $ domain ) ; $ entity = $ this -> get ( 'asm_translation_loader.translation_manager' ) -> findTranslationBy ( array ( 'transKey' => $ key , 'transLocale' => $ request -> getLocale ( ) , 'messageDomain' => $ domain , ) ) ; return array ( 'entity' => $ entity , 'delete_form' => $ deleteForm -> createView ( ) , ) ; } | Finds and displays a translation entity . |
528 | public function editAction ( Request $ request , $ key , $ domain ) { $ translation = $ this -> get ( 'asm_translation_loader.translation_manager' ) -> findTranslationBy ( array ( 'transKey' => $ key , 'transLocale' => $ request -> getLocale ( ) , 'messageDomain' => $ domain , ) ) ; $ entity = new Translation ( ) ; $ entity -> setKey ( $ translation -> getTransKey ( ) ) ; $ entity -> setDomain ( $ domain ) ; foreach ( $ this -> getParameter ( 'a2lix_translation_form.locales' ) as $ k => $ loc ) { $ translation = $ this -> get ( 'asm_translation_loader.translation_manager' ) -> findTranslationBy ( array ( 'transKey' => $ key , 'transLocale' => $ loc , 'messageDomain' => $ domain , ) ) ; if ( $ translation ) { $ trans = new TranslationTranslation ( ) ; $ trans -> setLocale ( $ loc ) ; $ trans -> setValue ( $ translation -> getTranslation ( ) ) ; $ entity -> addTranslation ( $ trans ) ; } } $ deleteForm = $ this -> createDeleteForm ( $ key , $ domain ) ; $ editForm = $ this -> createForm ( 'CoreBundle\Form\TranslationType' , $ entity ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isSubmitted ( ) && $ editForm -> isValid ( ) ) { $ this -> updateTranslation ( $ entity ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'translation.edited' ) ; return $ this -> redirectToRoute ( 'core_translation_index' ) ; } return $ this -> render ( 'CoreBundle:Translation:edit.html.twig' , array ( 'entity' => $ entity , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ) ; } | Displays a form to edit an existing translation entity . |
529 | public function deleteAction ( Request $ request , $ key , $ domain ) { $ form = $ this -> createDeleteForm ( $ key , $ domain ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ translation = $ this -> get ( 'asm_translation_loader.translation_manager' ) -> findTranslationBy ( array ( 'transKey' => $ key , 'transLocale' => $ request -> getLocale ( ) , 'messageDomain' => $ domain , ) ) ; $ this -> get ( 'asm_translation_loader.translation_manager' ) -> removeTranslation ( $ translation ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'translation.deleted' ) ; } return $ this -> redirectToRoute ( 'core_translation_index' ) ; } | Deletes a translation entity . |
530 | private function createDeleteForm ( $ key , $ domain ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'core_translation_delete' , array ( 'key' => $ key , 'domain' => $ domain ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; } | Creates a form to delete a translation entity . |
531 | static function createWorkflow ( $ workflow_config ) { self :: validateConfig ( $ workflow_config ) ; self :: validateState ( $ workflow_config [ self :: CONF_HANDLER ] , $ workflow_config [ self :: CONF_INITIAL_STATE ] ) ; if ( ! isset ( $ workflow_config [ "name" ] ) ) { $ workflow_config [ "name" ] = $ workflow_config [ self :: CONF_HANDLER ] . '(' . implode ( "," , $ workflow_config [ self :: CONF_PARAMS ] ) . ")" ; } if ( ! isset ( $ workflow_config [ "active" ] ) ) { $ workflow_config [ "active" ] = true ; } if ( ! isset ( $ workflow_config [ "max_age" ] ) ) { $ workflow_config [ "max_age" ] = Moment :: ONEDAY - Moment :: ONEHOUR ; } $ workflow_config [ "application" ] = Util :: getApplicationId ( ) ; $ workflow_config [ "service" ] = Util :: getModuleId ( ) ; $ workflow_config [ "created" ] = new \ DateTime ( ) ; $ workflow_key = self :: createWorkflowKeyFromConfig ( $ workflow_config ) ; DataStore :: saveWorkflow ( $ workflow_key , $ workflow_config ) ; return $ workflow_config ; } | Function creates and saves the workflow_config . |
532 | static function runFromConfig ( $ workflow_config , $ workflow_state ) { $ workflow_classname = $ workflow_config [ self :: CONF_HANDLER ] ; self :: validateConfig ( $ workflow_config ) ; self :: validateState ( $ workflow_classname , $ workflow_state ) ; $ workflow_params = $ workflow_config [ self :: CONF_PARAMS ] ; $ workflowClass = new $ workflow_classname ( $ workflow_config ) ; syslog ( LOG_INFO , "Running $workflow_classname with start state " . json_encode ( $ workflow_state ) ) ; call_user_func_array ( [ $ workflowClass , "setState" ] , $ workflow_state ) ; $ end_state = call_user_func_array ( [ $ workflowClass , "run" ] , $ workflow_params ) ; syslog ( LOG_INFO , "Ending $workflow_classname with end state " . json_encode ( $ end_state ) ) ; self :: validateState ( $ workflow_config [ self :: CONF_HANDLER ] , $ end_state ) ; return $ end_state ; } | This does not do any checks towards the database if there is jobs running . |
533 | static function isWorkflowInErrorState ( $ workflow_key , $ error_ttl ) { $ status = self :: STATUS_FAILED ; $ created_after = "-$error_ttl seconds" ; $ data = DataStore :: retrieveMostCurrentWorkflowJobByAgeAndStatus ( $ workflow_key , $ status , $ created_after ) ; return ( bool ) $ data ; } | Checks if its long since last error . This allows us to not spam apis with error for instance . |
534 | static function getWorkflowState ( $ workflow_key ) { $ status = self :: STATUS_COMPLETED ; $ created_after = "-20 years" ; $ data = DataStore :: retrieveMostCurrentWorkflowJobByAgeAndStatus ( $ workflow_key , $ status , $ created_after ) ; if ( $ data ) { return $ data [ "end_state" ] ; } else { $ workflow = DataStore :: retrieveWorkflow ( $ workflow_key ) ; if ( ! $ workflow ) { throw new \ Exception ( "Error retrieving workflow for key $workflow_key can't determine state." ) ; } $ data = $ workflow -> getData ( ) ; return $ data [ self :: CONF_INITIAL_STATE ] ; } } | Will check the last successful job and retrive state from it . |
535 | static function isWorkflowRunning ( $ workflow_key ) { $ status = self :: STATUS_RUNNING ; if ( Util :: isDevServer ( ) ) { $ created_after = "-60 seconds" ; } else { $ created_after = "-" . Moment :: ONEHOUR . " seconds" ; } $ data = DataStore :: retrieveMostCurrentWorkflowJobByAgeAndStatus ( $ workflow_key , $ status , $ created_after ) ; $ result = ( bool ) $ data ; return $ result ; } | Will check if there is still a job running |
536 | static function startJob ( $ workflow_job_key , $ workflow_job_config , $ start_state ) { $ workflow_key = self :: createWorkflowKeyFromConfig ( $ workflow_job_config ) ; $ workflow_name = $ workflow_job_config [ "name" ] ; if ( self :: isWorkflowRunning ( $ workflow_key ) ) { throw new \ Exception ( "A job for $workflow_name is already running." ) ; } $ error_ttl = Util :: isDevServer ( ) ? 60 : Moment :: ONEDAY ; if ( self :: isWorkflowInErrorState ( $ workflow_key , $ error_ttl ) ) { throw new \ Exception ( "A job for $workflow_name have failed less than $error_ttl seconds ago, skipping." ) ; } $ workflow_job_config = array_merge ( $ workflow_job_config , [ "status" => self :: STATUS_RUNNING , "start_state" => $ start_state , "end_state" => $ start_state , "finished" => new \ DateTime ( ) , ] ) ; DataStore :: saveWorkflowJob ( $ workflow_job_key , $ workflow_job_config ) ; return $ workflow_job_config ; } | Returns the workflow state from previous job . Performs the check on the previous job . Returns the state form the previous job . |
537 | static function endJob ( $ workflow_job_key , $ workflow_job_config , $ end_state = [ ] ) { $ workflow_job_config = array_merge ( $ workflow_job_config , [ "status" => self :: STATUS_COMPLETED , "end_state" => $ end_state , "finished" => new \ DateTime ( ) ] ) ; DataStore :: saveWorkflowJob ( $ workflow_job_key , $ workflow_job_config ) ; return $ workflow_job_config ; } | Returnes a report . |
538 | static function endpointHandler ( RequestInterface $ request ) { $ get_param = "workflow_key" ; $ query_params = Util :: getParamsFromRequest ( $ request ) ; if ( isset ( $ query_params [ $ get_param ] ) ) { $ result = self :: runFromKey ( $ query_params [ $ get_param ] ) ; return $ result ; } else { $ workflows = DataStore :: retrieveActiveWorkflows ( ) ; $ result = [ ] ; if ( $ workflows ) { $ url_path = $ request -> getUri ( ) -> getPath ( ) ; foreach ( $ workflows as $ flow ) { $ flow_key = self :: createWorkflowKeyFromConfig ( $ flow ) ; $ query_data = [ $ get_param => $ flow_key ] ; $ result [ ] = Tasks :: add ( $ url_path , $ query_data ) ; } Tasks :: flush ( ) ; } else { syslog ( LOG_WARNING , __METHOD__ . " could not find active workflows to schedule." ) ; } return $ result ; } } | Handler that can be use to as an endpoint to perform various . |
539 | public function renderJs ( ) { $ javascriptType = $ this -> getJavascriptType ( ) ; $ conditionJavascript = $ this -> getCondition ( ) -> renderJs ( ) ; $ fieldName = $ this -> getField ( ) -> getName ( ) ; $ formName = $ this -> getForm ( ) -> getName ( ) ; return sprintf ( "new GFormDependency(GFormDependency.%s, '%s.%s', %s)" , $ javascriptType , $ formName , $ fieldName , $ conditionJavascript ) ; } | Returns javascript part for dependency |
540 | public function getTemplateAccessors ( ) { if ( $ this -> templateAccessors ) return $ this -> templateAccessors ; $ vars = parent :: getTemplateAccessors ( ) ; return $ this -> templateAccessors = array_merge ( $ vars , array ( 'To' , 'Cc' , 'Bcc' , 'From' , 'Subject' , 'Body' , 'BaseURL' , 'IsEmail' ) ) ; } | Gets all the template accessors and caches the result |
541 | public function execute ( \ Sigbits \ RoombaLib \ SCI \ Command $ command ) { $ this -> connection -> write ( $ command ) ; } | Sends a command to the connection |
542 | public function Set ( $ sKey , $ mValue ) { if ( ! empty ( $ this -> sModuleName ) ) Storage :: Set ( "app." . $ this -> sModuleName . "." . $ sKey , $ mValue ) ; return $ this ; } | Function to set module settings |
543 | protected function reconcileNames ( $ item ) { if ( ! property_exists ( $ item , 'title' ) && property_exists ( $ item , 'name' ) ) { $ item -> title = $ item -> name ; } } | Method to reconcile non standard names from components to usage in this class . Typically overriden in the component feed view class . |
544 | public function getAuthenticatedRequest ( $ method , $ url , $ token , array $ options = [ ] ) { $ options [ 'headers' ] [ 'Accept' ] = 'application/vnd.api+json, application/vnd.api+json; net.youthweb.api.version=0.9' ; $ options [ 'headers' ] [ 'Content-Type' ] = 'application/vnd.api+json' ; return parent :: getAuthenticatedRequest ( $ method , $ url , $ token , $ options ) ; } | Returns an authenticated PSR - 7 request instance for Youthweb - API . |
545 | public function logoutAction ( ) { $ this -> getUserService ( ) -> getAuthService ( ) -> getStorage ( ) -> clear ( ) ; $ this -> getUserService ( ) -> getAuthService ( ) -> clearIdentity ( ) ; return $ this -> redirect ( ) -> toRoute ( 'small-user-auth' , [ 'action' => 'logout-page' ] ) ; } | Logout and clear the identity + Redirect to fix the identity |
546 | public function buildCommand ( ) { $ this -> cleanCommand ( ) ; $ framework = new Generator \ Framework ; $ atomicKitten = new Generator \ AtomicKitten ; $ framework -> build ( ) ; $ this -> outputLine ( 'Generation of framework finished.' , [ ] , CommandController :: OK ) ; $ atomicKitten -> build ( ) ; $ this -> outputLine ( 'Generation finished.' , [ ] , CommandController :: OK ) ; } | Will generate the static AtomicKitten . |
547 | public function cleanCommand ( ) { if ( is_dir ( $ this -> buildSettings [ 'target' ] ) ) { \ TYPO3 \ Flow \ Utility \ Files :: removeDirectoryRecursively ( $ this -> buildSettings [ 'target' ] ) ; } mkdir ( $ this -> buildSettings [ 'target' ] ) ; $ this -> outputLine ( 'Cleaned target folder.' , [ ] , CommandController :: OK ) ; } | Will remove all generated files . |
548 | protected function updateNodeResponse ( Response $ response , ReadNodeInterface $ node , Request $ request ) { $ tagManager = $ this -> get ( 'open_orchestra_base.manager.tag' ) ; $ cacheableManager = $ this -> get ( 'open_orchestra_display.manager.cacheable' ) ; $ cacheTags = array ( $ tagManager -> formatNodeIdTag ( $ node -> getNodeId ( ) ) , $ tagManager -> formatLanguageTag ( $ node -> getLanguage ( ) ) , $ tagManager -> formatSiteIdTag ( $ node -> getSiteId ( ) ) ) ; $ cacheableManager -> addCacheTags ( $ cacheTags ) ; $ cacheInfo = $ this -> get ( 'open_orchestra_front.manager.node_response_manager' ) -> getNodeCacheInfo ( $ node ) ; $ privacy = ( $ cacheInfo [ NodeResponseManager :: IS_PUBLIC ] ) ? CacheableInterface :: CACHE_PUBLIC : CacheableInterface :: CACHE_PRIVATE ; if ( $ this -> has ( 'esi' ) && $ this -> get ( 'esi' ) -> hasSurrogateCapability ( $ request ) ) { $ response = $ cacheableManager -> setResponseCacheParameters ( $ response , ( CacheableInterface :: CACHE_PUBLIC === $ privacy ) ? $ node -> getMaxAge ( ) : 0 , $ privacy , true ) ; } else { $ response = $ cacheableManager -> setResponseCacheParameters ( $ response , ( CacheableInterface :: CACHE_PUBLIC === $ privacy ) ? $ cacheInfo [ NodeResponseManager :: MAX_AGE ] : 0 , $ privacy ) ; } return $ response ; } | Update response headers |
549 | protected function getMissingEntities ( ) { $ modes = $ this -> getAllModes ( ) ; $ entrySubtypes = $ this -> getEntrySubtypes ( ) ; $ classes = array ( ) ; foreach ( $ entrySubtypes as $ service => $ subtypes ) { foreach ( $ modes as $ mode ) { foreach ( $ subtypes as $ subtype ) { $ classes [ ] = sprintf ( self :: MODE_PATTERN , $ service , $ mode , $ service . $ subtype . $ mode ) ; } } } return $ this -> getMissingClasses ( $ classes ) ; } | Checks if each Entry has an Entity for all Modes . |
550 | public function setContentId ( $ id ) { $ this -> contentId = empty ( $ id ) ? null : ( int ) $ id ; $ this -> _uriCache = null ; $ this -> _visible = null ; return $ this ; } | Setter for content - id |
551 | public function setSubdomainId ( $ id ) { $ this -> subdomainId = empty ( $ id ) ? null : ( int ) $ id ; $ this -> _uriCache = null ; return $ this ; } | Setter for subdomain - id |
552 | public function getUriModel ( ) { if ( null === $ this -> _uriModel ) { $ this -> _uriModel = $ this -> getServiceLocator ( ) -> get ( 'Grid\Core\Model\Uri\Model' ) ; } return $ this -> _uriModel ; } | Get the stored uri - mapper |
553 | public function getSubDomainModel ( ) { if ( null === $ this -> _subDomainModel ) { $ this -> _subDomainModel = $ this -> getServiceLocator ( ) -> get ( 'Grid\Core\Model\SubDomain\Model' ) ; } return $ this -> _subDomainModel ; } | Get the stored subdomain - mapper |
554 | public function getParagraphModel ( ) { if ( null === $ this -> _paragraphModel ) { $ this -> _paragraphModel = $ this -> getServiceLocator ( ) -> get ( 'Grid\Paragraph\Model\Paragraph\Model' ) ; } return $ this -> _paragraphModel ; } | Get the stored paragraph - mapper |
555 | public function getUri ( ) { if ( empty ( $ this -> _uriCache ) ) { $ subdomainId = $ this -> getSubdomainId ( ) ; $ info = $ this -> getServiceLocator ( ) -> get ( 'Zork\Db\SiteInfo' ) ; if ( empty ( $ subdomainId ) ) { $ subdomainId = $ info -> getSubdomainId ( ) ; } else if ( $ subdomainId != $ info -> getSubdomainId ( ) ) { $ subdomain = $ this -> getSubDomainModel ( ) -> find ( $ subdomainId ) ; if ( empty ( $ subdomain ) ) { $ subdomainId = $ info -> getSubdomainId ( ) ; } } if ( ! empty ( $ this -> contentId ) ) { $ base = '/' ; $ locale = $ this -> getMapper ( ) -> getLocale ( ) ; $ uri = $ this -> getUriModel ( ) -> findDefaultByContentSubdomain ( $ this -> getContentId ( ) , $ subdomainId , $ locale ) ; if ( ! empty ( $ subdomain ) ) { $ base = $ info -> getSubdomainUrl ( ( string ) $ subdomain -> subdomain , $ base ) ; } if ( empty ( $ uri ) ) { $ uri = $ base . 'app/' . $ locale . '/paragraph/render/' . $ this -> getContentId ( ) ; } else { $ uri = $ base . ltrim ( $ uri -> safeUri , '/' ) ; $ this -> _uriCache = $ uri ; } return $ uri ; } } return $ this -> _uriCache ; } | Getter for uri |
556 | public static function listenToContextLoadFactoriesEvent ( sfEvent $ event ) { $ context = $ event -> getSubject ( ) ; if ( sfContext :: getInstance ( ) -> getConfiguration ( ) -> getEnvironment ( ) == 'dev' ) { $ context -> getResponse ( ) -> addStylesheet ( twAdmin :: getProperty ( 'web_dir' ) . '/css/bootstrap.css' , 'first' ) ; $ context -> getResponse ( ) -> addStylesheet ( twAdmin :: getProperty ( 'web_dir' ) . '/css/bootstrap-responsive.css' ) ; $ context -> getResponse ( ) -> addStylesheet ( twAdmin :: getProperty ( 'web_dir' ) . '/css/smoothness/jquery-ui-1.10.1.custom.css' ) ; } else { $ context -> getResponse ( ) -> addStylesheet ( twAdmin :: getProperty ( 'web_dir' ) . '/css/bootstrap.min.css' , 'first' ) ; $ context -> getResponse ( ) -> addStylesheet ( twAdmin :: getProperty ( 'web_dir' ) . '/css/bootstrap-responsive.min.css' ) ; $ context -> getResponse ( ) -> addStylesheet ( twAdmin :: getProperty ( 'web_dir' ) . '/css/smoothness/jquery-ui-1.10.1.custom.min.css' ) ; } $ context -> getResponse ( ) -> addStylesheet ( twAdmin :: getProperty ( 'web_dir' ) . '/css/jquery-ui-timepicker-addon.css' ) ; $ context -> getResponse ( ) -> addStylesheet ( twAdmin :: getProperty ( 'web_dir' ) . '/css/twadmin.css' , 'last' ) ; if ( sfContext :: getInstance ( ) -> getConfiguration ( ) -> getEnvironment ( ) == 'dev' ) { $ context -> getResponse ( ) -> addJavascript ( twAdmin :: getProperty ( 'web_dir' ) . '/js/jquery-1.9.1.js' ) ; $ context -> getResponse ( ) -> addJavascript ( twAdmin :: getProperty ( 'web_dir' ) . '/js/bootstrap.js' ) ; $ context -> getResponse ( ) -> addJavascript ( twAdmin :: getProperty ( 'web_dir' ) . '/js/jquery-ui-1.10.1.custom.js' ) ; } else { $ context -> getResponse ( ) -> addJavascript ( twAdmin :: getProperty ( 'web_dir' ) . '/js/jquery-1.9.1.min.js' ) ; $ context -> getResponse ( ) -> addJavascript ( twAdmin :: getProperty ( 'web_dir' ) . '/js/bootstrap.min.js' ) ; $ context -> getResponse ( ) -> addJavascript ( twAdmin :: getProperty ( 'web_dir' ) . '/js/jquery-ui-1.10.1.custom.min.js' ) ; } $ context -> getResponse ( ) -> addJavascript ( twAdmin :: getProperty ( 'web_dir' ) . '/js/jquery-ui-timepicker-addon.js' ) ; $ context -> getResponse ( ) -> addJavascript ( twAdmin :: getProperty ( 'web_dir' ) . '/js/jquery-ui-datepicker-pl.js' ) ; $ context -> getResponse ( ) -> addJavascript ( twAdmin :: getProperty ( 'web_dir' ) . '/js/twadmin.js' , 'last' ) ; } | After the context has been initiated we can add the required assets |
557 | public function createSubModule ( $ className ) { if ( ! class_exists ( $ className ) || ! is_subclass_of ( $ className , '\LiftKit\Module\Module' ) ) { throw new NonexistentSubModuleException ( 'Class name is not module: ' . $ className ) ; } return new $ className ( $ this -> container ) ; } | This method accepts a fully - qualified class name and creates it . |
558 | public static function getInstance ( $ basepath = null , $ classprefix = 'JInstallerAdapter' , $ adapterfolder = 'adapter' ) { if ( $ basepath === null ) { $ basepath = JPATH_LIBRARIES . '/cms/installer' ; } return parent :: getInstance ( $ basepath , $ classprefix , $ adapterfolder ) ; } | Returns the global Installer object only creating it if it doesn t already exist . |
559 | public function getEdit ( $ id = null ) { $ group = Sentinel :: getRoleRepository ( ) -> find ( $ id ) ; if ( $ group == null ) { $ error = Lang :: get ( 'base.groups.not_found' ) ; return Redirect :: route ( 'groups' ) -> with ( 'error' , $ error ) ; } $ groups = null ; $ groups2 = Sentinel :: getRoleRepository ( ) -> all ( [ 'id' , 'name' ] ) ; foreach ( $ groups2 as $ g ) $ groups [ $ g -> id ] = $ g -> name ; return View ( 'admin.groups.edit' , compact ( 'group' , 'groups' ) ) ; } | Group update . |
560 | public function postEdit ( $ id = null ) { $ group = Sentinel :: getRoleRepository ( ) -> find ( $ id ) ; if ( $ group == null ) { $ error = Lang :: get ( 'base.groups.not_found' ) ; return Redirect :: route ( 'admin.blogs.show' ) -> with ( 'error' , $ error ) ; } unset ( $ this -> validationRules [ 'slug' ] ) ; $ this -> validationRules [ 'slug' ] = "required|min:3|unique:Group,slug,{$group->slug},slug" ; $ slug = str_slug ( Input :: get ( 'name' ) , '_' ) ; $ input = Input :: all ( ) ; $ input [ 'slug' ] = $ slug ; $ validator = Validator :: make ( $ input , $ this -> validationRules ) ; if ( $ validator -> fails ( ) ) { return Redirect :: back ( ) -> withInput ( ) -> withErrors ( $ validator ) ; } $ group -> name = Input :: get ( 'name' ) ; $ group -> slug = $ slug ; $ group -> description = Input :: get ( 'description' ) ; if ( $ group -> save ( ) ) { Base :: Log ( 'Group (' . $ group -> id . ' - ' . $ group -> name . ') was edited.' ) ; $ success = Lang :: get ( 'base.groups.changed' ) ; return Redirect :: route ( 'groups' ) -> with ( 'success' , $ success ) ; } $ error = Lang :: get ( 'base.groups.error' ) ; return Redirect :: route ( 'groups.update' , $ id ) -> withInput ( ) -> with ( 'error' , $ error ) ; } | Group update form processing page . |
561 | public function getCreate ( ) { $ groups = null ; $ groups2 = Sentinel :: getRoleRepository ( ) -> all ( [ 'id' , 'name' ] ) ; foreach ( $ groups2 as $ g ) $ groups [ $ g -> id ] = $ g -> name ; return View ( 'admin.groups.create' , compact ( 'groups' ) ) ; } | Create new group |
562 | public function postCreate ( ) { $ slug = str_slug ( Input :: get ( 'name' ) , '_' ) ; $ input = Input :: all ( ) ; $ input [ 'slug' ] = $ slug ; $ validator = Validator :: make ( $ input , $ this -> validationRules ) ; if ( $ validator -> fails ( ) ) { return Redirect :: back ( ) -> withInput ( ) -> withErrors ( $ validator ) ; } $ group = Sentinel :: getRoleRepository ( ) -> findBySlug ( $ slug ) ; if ( $ group != null ) return Redirect :: route ( "groups" ) -> with ( 'error' , Lang :: get ( 'base.groups.already_exists' ) ) ; $ group = Sentinel :: getRoleRepository ( ) -> create ( [ 'name' => Input :: get ( 'name' ) , 'slug' => $ slug , 'description' => Input :: get ( 'description' ) , ] ) ; $ group -> save ( ) ; Base :: Log ( 'A new group (' . $ group -> id . ' - ' . $ group -> name . ') was created.' ) ; return Redirect :: route ( "groups" ) -> with ( 'success' , Lang :: get ( 'base.groups.created' ) ) ; } | Group create form processing . |
563 | public function getDelete ( $ id = null ) { $ group = Sentinel :: getRoleRepository ( ) -> find ( $ id ) ; if ( $ group == null ) { $ error = Lang :: get ( 'base.groups.not_found' ) ; return Redirect :: route ( 'groups' ) -> with ( 'error' , $ error ) ; } Base :: Log ( 'Group (' . $ group -> id . ' - ' . $ group -> name . ') was deleted.' ) ; $ group -> delete ( ) ; $ success = Lang :: get ( 'base.groups.deleted' ) ; return Redirect :: route ( 'groups' ) -> with ( 'success' , $ success ) ; } | Delete the given group . |
564 | public function getClient ( ) { if ( null === $ this -> client ) { $ this -> client = S3Client :: factory ( [ 'version' => 'latest' , 'region' => $ this -> getRegion ( ) ] ) ; } return $ this -> client ; } | Instantiates and returns an S3Client instance |
565 | public function setVisibility ( string $ visibility ) { if ( ! in_array ( $ visibility , VisibilityableInterface :: VISIBILITY_ALLOWED ) ) { throw new \ Exception ( sprintf ( VisibilityableInterface :: ERROR_FORMAT_INVALID_VISIBILITY , $ visibility ) ) ; } $ this -> visibility = $ visibility ; return $ this ; } | Sets the visibility |
566 | public function remove ( ... $ items ) { foreach ( $ items as $ item ) if ( ( $ index = $ this -> indexOf ( $ item ) ) !== null ) unset ( $ this -> items [ $ index ] ) ; return $ this ; } | Remove an item from list |
567 | public function add ( ... $ items ) { foreach ( $ items as & $ item ) $ item = ( array ) $ item ; $ this -> items = array_merge ( $ this -> items , ... $ items ) ; return $ this ; } | Add an item to list |
568 | public function getItems ( $ keys = null ) { if ( $ keys ) return array_intersect_key ( $ this -> items , array_flip ( $ keys ) ) ; return $ this -> items ; } | Retreive list as array |
569 | public function sendPasswordNotification ( $ token , $ request ) { $ this -> notify ( new SetPasswordNotification ( $ token , $ request -> tenant , $ request -> site ) ) ; } | Send the new account notification . |
570 | public function sendResetPasswordNotification ( $ token , $ request ) { $ this -> notify ( new ResetPasswordNotification ( $ token , $ request -> tenant , $ request -> site ) ) ; } | Send the password reset email . |
571 | public function forceLogin ( ) : bool { if ( $ this -> loggedIn ( ) ) { return true ; } $ router = $ this -> di -> get ( 'core.router' ) ; $ router -> setApp ( 'Core' ) ; $ router -> setController ( 'Login' ) ; $ router -> setAction ( 'Login' ) ; return false ; } | Checks login state and overrides the router current data to force display of loginform . |
572 | private function logLogin ( bool $ error_username = false , bool $ error_password = false , bool $ ban = true ) { $ text = sprintf ( 'Login for user "%s"' , $ this -> username ) ; $ state = 0 ; if ( $ error_username || $ error_password ) { $ text .= ' failed because of wrong ' ; if ( $ error_username ) { $ state += 1 ; $ text .= 'username' ; } if ( $ error_password ) { $ state += 2 ; $ text .= 'password' ; } if ( $ this -> ban && $ ban ) { $ banlog = new BanLogEntry ( $ this -> db ) ; $ banlog -> setText ( $ text ) ; $ banlog -> setCode ( $ state ) ; $ banlog -> add ( ) ; } if ( isset ( $ this -> logger ) ) { $ this -> logger -> warning ( $ text , [ $ state ] ) ; } return ; } if ( isset ( $ this -> logger ) ) { $ this -> logger -> info ( $ text . ' success' ) ; } } | Logs login process |
573 | public function toView ( $ prefix = null , array $ restricted = array ( ) ) { return array ( $ prefix . 'name' => $ this -> name , $ prefix . 'surname' => $ this -> surname , $ prefix . 'socialID' => $ this -> socialID , $ prefix . 'email' => $ this -> email , $ prefix . 'birthday' => $ this -> birthday , $ prefix . 'gender' => $ this -> gender , $ prefix . 'locale' => $ this -> locale , $ prefix . 'photo' => $ this -> photo , $ prefix . 'other' => $ this -> other ) ; } | Transform object for view rendering |
574 | public function initialize ( Application $ app , Renderer $ renderer ) { switch ( $ app -> config ( 'renderer.name' ) ) { case 'twig' : $ this -> initialize4Twig ( $ app , $ renderer ) ; break ; } } | callback on initialize . |
575 | protected function initialize4Twig ( Application $ app , Renderer $ renderer ) { \ Twig_Autoloader :: register ( ) ; $ twig_loader = null ; foreach ( $ app -> loader -> find ( $ app -> config ( 'directory.template' ) ) as $ dir ) { if ( ! $ twig_loader ) { $ twig_loader = new \ Twig_Loader_Filesystem ( $ dir -> getRealPath ( ) ) ; } else { $ twig_loader -> addPath ( $ dir -> getRealPath ( ) ) ; } } if ( $ twig_loader ) { foreach ( $ app -> loader -> find ( $ app -> config ( 'directory.layout' ) ) as $ dir ) { $ twig_loader -> addPath ( $ dir -> getRealPath ( ) , 'layout' ) ; } } $ twig = $ renderer -> getEngine ( ) ; $ twig -> setLoader ( $ twig_loader ) ; $ twig -> setCache ( $ app -> loader -> find ( $ app -> config ( 'directory.temp' ) ) -> first ( ) . DS . 'twig' ) ; if ( $ app -> config ( 'renderer.auto_reload' ) ) $ twig -> enableAutoReload ( ) ; if ( ! $ app -> config ( 'renderer.auto_escape_html' ) ) { $ twig -> removeExtension ( 'escaper' ) ; } $ renderer -> set ( 'config' , $ app -> configHierarchical ( ) ) ; $ renderer -> setComponent ( 'html' , new HtmlHelper ( ) ) ; } | initialize for twig . |
576 | public function create ( Environment $ environment ) { $ files = $ environment -> getFiles ( ) ; $ parsed = $ this -> parseFiles ( $ files ) ; return $ parsed ; } | Create instances of UploadedFile object from instance of Environment object |
577 | private function parseFiles ( $ files ) { $ parsed = [ ] ; if ( ! empty ( $ files ) ) { foreach ( $ files as $ field => $ file ) { $ parsed [ $ field ] = $ this -> parseFile ( $ file ) ; } } return $ parsed ; } | Parse files data into instances of UploadedFile |
578 | private function parseFile ( $ uploadedFile ) { $ item = [ ] ; if ( is_array ( $ uploadedFile ) ) { if ( ! is_array ( $ uploadedFile [ 'error' ] ) ) { $ item [ ] = new UploadedFile ( $ uploadedFile [ 'tmp_name' ] , isset ( $ uploadedFile [ 'name' ] ) ? $ uploadedFile [ 'name' ] : null , isset ( $ uploadedFile [ 'type' ] ) ? $ uploadedFile [ 'type' ] : null , isset ( $ uploadedFile [ 'size' ] ) ? $ uploadedFile [ 'size' ] : null , $ uploadedFile [ 'error' ] ) ; } else { foreach ( $ uploadedFile [ 'error' ] as $ fieldIndex => $ void ) { $ item [ ] = new UploadedFile ( $ uploadedFile [ 'tmp_name' ] [ $ fieldIndex ] , isset ( $ uploadedFile [ 'name' ] ) ? $ uploadedFile [ 'name' ] [ $ fieldIndex ] : null , isset ( $ uploadedFile [ 'type' ] ) ? $ uploadedFile [ 'type' ] [ $ fieldIndex ] : null , isset ( $ uploadedFile [ 'size' ] ) ? $ uploadedFile [ 'size' ] [ $ fieldIndex ] : null , $ uploadedFile [ 'error' ] [ $ fieldIndex ] ) ; } } } return $ item ; } | Parse particular fields in files data into instances of UploadedFile |
579 | public static function setUserTags ( ) { self :: fetchUserTags ( ) ; $ namespace = 'App\View\Atomium\UserTag\\' ; foreach ( get_declared_classes ( ) as $ value ) { if ( strpos ( $ value , $ namespace ) !== false ) { self :: $ userTags [ ] = $ value ; } } } | Set User Tags . |
580 | protected static function fetchUserTags ( ) { $ files = Bus :: fetch ( 'resources/tags' , false ) ; if ( ! is_null ( $ files ) ) { foreach ( Bus :: fetch ( 'resources/tags' , false ) as $ file ) { Bus :: need ( $ file ) ; } } } | Fetch User Tags . |
581 | protected static function compileUserTags ( ) { if ( ! is_null ( self :: $ userTags ) ) { foreach ( self :: $ userTags as $ compiler ) { self :: $ output = $ compiler :: run ( self :: $ output ) ; } } } | Compile User Tags . |
582 | protected function outputUri ( $ mtime ) { return Thumbnail :: THUMBNAIL_BASEURI . '/' . $ this -> path . '/' . $ this -> method . '/' . ( empty ( $ this -> crop ) ? '' : $ this -> cropLeft . 'x' . $ this -> cropTop . '-' . $ this -> cropWidth . 'x' . $ this -> cropHeight . '-' ) . $ this -> width . 'x' . $ this -> height . '/' . $ this -> bgColor . '/' . ( empty ( $ this -> filters ) ? 'none' : implode ( '-' , ( array ) $ this -> filters ) ) . '/' . $ mtime . '/' . $ this -> file ; } | Get output uri for settings |
583 | public function execute ( ) { $ action = $ this -> action ( ) ; if ( ! is_callable ( array ( $ this , $ action ) ) ) { $ errorMessage = 'The action <b>' . $ this -> action . '</b> is not defined for the module <b>' . ucfirst ( $ this -> module ) . '</b>' ; throw new \ RuntimeException ( $ errorMessage , MvcErrors :: ACTION_NOT_FOUND_FOR_CONTROLLER , null ) ; } $ logGuid = \ Puzzlout \ Framework \ Utility \ TimeLogger :: StartLogInfo ( $ this -> app ( ) , get_class ( $ this ) . "->" . ucfirst ( $ action ) ) ; $ viewModelObject = $ this -> $ action ( ) ; \ Puzzlout \ Framework \ Utility \ TimeLogger :: EndLog ( $ this -> app ( ) , $ logGuid ) ; return $ viewModelObject ; } | Execute the Controller action . |
584 | public function setModule ( $ module ) { if ( ! is_string ( $ module ) || empty ( $ module ) ) { $ errMessage = "The module value must be a string and not be empty" ; throw new \ InvalidArgumentException ( $ errMessage , GeneralErrors :: VALUE_IS_NOT_OF_EXPECTED_TYPE ) ; } $ this -> module = $ module ; } | Save the module in the instance . |
585 | public function setAction ( $ action ) { if ( ! is_string ( $ action ) || empty ( $ action ) ) { $ errMessage = "The action value must be a string and not be empty" ; throw new \ InvalidArgumentException ( $ errMessage , GeneralErrors :: VALUE_IS_NOT_OF_EXPECTED_TYPE ) ; } $ this -> action = $ action ; } | Save the action value in the instance . |
586 | public function setView ( ) { if ( ! is_string ( $ this -> action ) || empty ( $ this -> action ) ) { $ errMessage = 'The action value must be a string and not be empty' ; throw new \ InvalidArgumentException ( $ errMessage , GeneralErrors :: VALUE_IS_NOT_OF_EXPECTED_TYPE ) ; } if ( \ Puzzlout \ Framework \ Core \ Request :: Init ( $ this -> app ) -> IsPost ( ) ) { return ; } $ this -> view = \ Puzzlout \ Framework \ Core \ ViewLoader :: Init ( $ this ) -> GetView ( ) ; $ this -> page -> setContentFile ( $ this -> view ) ; } | Set the view filename for the current request . |
587 | public function AddGlobalAppVariables ( ) { $ context = new Context ( $ this -> app ) ; $ culture = $ context -> GetCultureLang ( ) . "_" . $ context -> GetCultureRegion ( ) ; $ this -> page ( ) -> addVar ( 'culture' , $ culture ) ; $ user = $ this -> app ( ) -> user -> getAttribute ( \ Puzzlout \ Framework \ Enums \ SessionKeys :: UserConnected ) ; $ this -> page ( ) -> addVar ( 'user' , $ user [ 0 ] ) ; $ this -> page ( ) -> addVar ( Router :: CurrentRouteVarKey , Router :: Init ( $ this -> app ) -> currentRoute ( ) ) ; } | Add the context the variables that are used to generated the output from the Views . |
588 | protected function resolveCallableArguments ( \ ReflectionFunctionAbstract $ reflector , $ args = [ ] ) { return array_map ( function ( \ ReflectionParameter $ parameter ) use ( $ args ) { $ name = $ parameter -> name ; $ class = $ parameter -> getClass ( ) ; if ( array_key_exists ( $ name , $ args ) ) { return $ args [ $ name ] ; } if ( $ class ) { return $ this -> get ( $ class -> name ) ; } if ( $ parameter -> isDefaultValueAvailable ( ) ) { return $ parameter -> getDefaultValue ( ) ; } throw new \ RuntimeException ( sprintf ( 'Cannot resolve argument [%s], it should be provided within an array of arguments passed to ' . '[%s::call], have a default value or be type hinted' , $ name , get_class ( $ this ) ) ) ; } , $ reflector -> getParameters ( ) ) ; } | Resolves arguments for a callable |
589 | public static function options ( $ key = null , $ value = null ) { $ options = static :: setup ( ) ; if ( ! $ key ) { return $ options ; } if ( ! $ value ) { return $ options [ $ key ] ?? null ; } static :: $ options [ $ key ] = $ value ; return static :: $ options ; } | Management to options of app |
590 | public function chunk ( $ size ) { $ chunks = array_chunk ( $ this -> all ( ) , $ size ) ; $ chunks = array_map ( function ( $ chunk ) { return new static ( $ chunk ) ; } , $ chunks ) ; return $ chunks ; } | Split collection into chunks |
591 | public function column ( $ key ) { $ result = array_column ( $ this -> all ( ) , $ key ) ; if ( empty ( $ result ) ) { $ this -> each ( function ( $ item ) use ( & $ result , $ key ) { array_push ( $ result , $ item -> { $ key } ) ; } ) ; } return new static ( $ result ) ; } | Retrieves the values from a single column in collection |
592 | public function filter ( \ Closure $ callback ) { $ results = array_filter ( $ this -> all ( ) , $ callback , ARRAY_FILTER_USE_BOTH ) ; return new static ( $ results ) ; } | Filters items of collection using a callback function |
593 | public function intersect ( ) { $ arrays = func_get_args ( ) ; $ arrays = array_map ( function ( $ array ) { return $ this -> getAvailableArray ( $ array ) ; } , $ arrays ) ; array_unshift ( $ arrays , $ this -> all ( ) ) ; $ arrays = call_user_func_array ( 'array_intersect' , $ arrays ) ; return new static ( $ arrays ) ; } | Computes the intersection of collection |
594 | public function join ( $ key , $ glue = null ) { if ( $ glue !== null ) { return $ this -> column ( $ key ) -> join ( $ glue ) ; } return implode ( $ key , $ this -> all ( ) ) ; } | Join collection items with a string you should pass the key of the attributes you wish to join |
595 | public function sum ( $ column ) { return $ this -> column ( $ column ) -> reduce ( function ( $ carry , $ item ) { $ carry += $ item ; return $ carry ; } ) ; } | Sum of all items in the collection by column |
596 | public static function all ( ) { $ paths = \ Config :: get ( 'module_paths' , array ( ) ) ; $ modules = array ( ) ; foreach ( $ paths as $ path ) { $ modules += array_map ( 'basename' , glob ( $ path . '*' , GLOB_ONLYDIR ) ) ; } sort ( $ modules ) ; return $ modules ; } | Lists all possible modules in all module paths |
597 | protected static function load_routes ( $ module , $ path ) { if ( is_file ( $ path .= 'config/routes.php' ) ) { $ module_routes = \ Fuel :: load ( $ path ) ; $ prefix = static :: get_prefix ( $ module ) ; $ prepped_routes = array ( ) ; foreach ( $ module_routes as $ name => $ _route ) { if ( $ name === '_root_' ) { $ name = $ prefix ; } elseif ( strpos ( $ name , $ prefix . '/' ) !== 0 and $ name != $ prefix and $ name !== '_404_' ) { $ name = $ prefix . '/' . $ name ; } $ prepped_routes [ $ name ] = $ _route ; } ; \ Router :: add ( $ prepped_routes , null , true ) ; } } | Loads the routes for the module |
598 | public static function addViewPath ( $ path ) { self :: $ _viewPaths = array_merge ( Option :: clean ( self :: $ _viewPaths ) , array ( $ path ) ) ; self :: $ _twigLoader = new \ Twig_Loader_Filesystem ( self :: $ _viewPaths ) ; self :: $ _twigEnvironment = new \ Twig_Environment ( self :: $ _twigLoader ) ; } | Adds a path to the view path |
599 | public static function twigView ( $ viewFile , $ payload = array ( ) , $ returnString = false ) { if ( null !== self :: $ _twigEnvironment ) { $ _output = self :: $ _twigEnvironment -> render ( $ viewFile , self :: _getBaseRenderPayload ( $ viewFile , $ payload ) ) ; if ( false !== $ returnString ) { return $ _output ; } echo $ _output ; } } | Renders a Twig template view |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.