idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
19,600 | public static function checkAndCreateTableByEntityName ( ContainerInterface $ container , $ className , $ force = false ) { $ doctrine = $ container -> get ( 'doctrine' ) ; $ manager = $ doctrine -> getManager ( ) ; $ schemaTool = new SchemaTool ( $ doctrine -> getManager ( ) ) ; $ connection = $ doctrine -> getConnection ( ) ; $ schemaManager = $ connection -> getSchemaManager ( ) ; $ classMetadata = $ manager -> getClassMetadata ( $ className ) ; if ( $ force || ! $ schemaManager -> tablesExist ( $ classMetadata -> getTableName ( ) ) ) { if ( $ schemaManager instanceof SqliteSchemaManager ) { $ columns = array ( ) ; $ identifiers = $ classMetadata -> getIdentifierColumnNames ( ) ; foreach ( $ classMetadata -> getFieldNames ( ) as $ fieldName ) { $ fieldMapping = $ classMetadata -> getFieldMapping ( $ fieldName ) ; $ columnSql = $ fieldMapping [ "fieldName" ] ; switch ( $ fieldMapping [ "type" ] ) { case 'integer' : $ columnSql .= " INTEGER " ; break ; case 'real' : case 'double' : case 'float' : $ columnSql .= " REAL " ; break ; case 'datetime' : case 'date' : case 'boolean' : $ columnSql .= " INTEGER " ; break ; case 'blob' : case 'file' : $ columnSql .= " BLOB " ; break ; default : $ columnSql .= " TEXT " ; } in_array ( $ fieldName , $ identifiers ) && $ columnSql .= "PRIMARY KEY " ; $ columnSql .= $ fieldMapping [ "nullable" ] ? "NULL " : "NOT NULL " ; $ columns [ ] = $ columnSql ; } $ sql = 'CREATE TABLE IF NOT EXISTS ' . $ classMetadata -> getTableName ( ) . '( ' . implode ( ",\n" , $ columns ) . ')' ; $ statement = $ connection -> query ( $ sql ) ; } else { $ schemaTool -> updateSchema ( array ( $ classMetadata ) , true ) ; } } } | Check and create table if not exists |
19,601 | public function actionFiles ( ) { $ sources = [ ] ; $ currentSource = $ this -> getSource ( ) ; foreach ( $ this -> config -> sources as $ key => $ source ) { if ( $ this -> request -> source && $ this -> request -> source !== 'default' && $ currentSource !== $ source && $ this -> request -> path !== './' ) { continue ; } if ( $ this -> accessControl -> isAllow ( $ this -> getUserRole ( ) , $ this -> action , $ source -> getPath ( ) ) ) { $ sources [ $ key ] = $ this -> read ( $ source ) ; } } return [ 'sources' => $ sources ] ; } | Load all files from folder ore source or sources |
19,602 | public function actionFolders ( ) { $ sources = [ ] ; foreach ( $ this -> config -> sources as $ key => $ source ) { if ( $ this -> request -> source && $ this -> request -> source !== 'default' && $ key !== $ this -> request -> source && $ this -> request -> path !== './' ) { continue ; } $ path = $ source -> getPath ( ) ; try { $ this -> accessControl -> checkPermission ( $ this -> getUserRole ( ) , $ this -> action , $ path ) ; } catch ( \ Exception $ e ) { continue ; } $ sourceData = ( object ) [ 'baseurl' => $ source -> baseurl , 'path' => str_replace ( realpath ( $ source -> getRoot ( ) ) . Consts :: DS , '' , $ path ) , 'folders' => [ ] , ] ; $ sourceData -> folders [ ] = $ path == $ source -> getRoot ( ) ? '.' : '..' ; $ dir = opendir ( $ path ) ; while ( $ file = readdir ( $ dir ) ) { if ( $ file != '.' && $ file != '..' && is_dir ( $ path . $ file ) and ( ! $ this -> config -> createThumb || $ file !== $ this -> config -> thumbFolderName ) and ! in_array ( $ file , $ this -> config -> excludeDirectoryNames ) ) { $ sourceData -> folders [ ] = $ file ; } } $ sources [ $ key ] = $ sourceData ; } return [ 'sources' => $ sources ] ; } | Load all folders from folder ore source or sources |
19,603 | public function actionFileUploadRemote ( ) { $ url = $ this -> request -> url ; if ( ! $ url ) { throw new \ Exception ( 'Need url parameter' , Consts :: ERROR_CODE_BAD_REQUEST ) ; } $ result = parse_url ( $ url ) ; if ( ! isset ( $ result [ 'host' ] ) || ! isset ( $ result [ 'path' ] ) ) { throw new \ Exception ( 'Not valid URL' , Consts :: ERROR_CODE_BAD_REQUEST ) ; } $ filename = Helper :: makeSafe ( basename ( $ result [ 'path' ] ) ) ; if ( ! $ filename ) { throw new \ Exception ( 'Not valid URL' , Consts :: ERROR_CODE_BAD_REQUEST ) ; } $ source = $ this -> config -> getCompatibleSource ( $ this -> request -> source ) ; Helper :: downloadRemoteFile ( $ url , $ source -> getRoot ( ) . $ filename ) ; $ file = new File ( $ source -> getRoot ( ) . $ filename ) ; try { if ( ! $ file -> isGoodFile ( $ source ) ) { throw new \ Exception ( 'Bad file' , Consts :: ERROR_CODE_FORBIDDEN ) ; } $ this -> accessControl -> checkPermission ( $ this -> getUserRole ( ) , $ this -> action , $ source -> getRoot ( ) , $ file -> getExtension ( ) ) ; } catch ( \ Exception $ e ) { $ file -> remove ( ) ; throw $ e ; } return [ 'newfilename' => $ file -> getName ( ) , 'baseurl' => $ source -> baseurl , ] ; } | Load remote image by URL to self host |
19,604 | private function movePath ( ) { $ source = $ this -> getSource ( ) ; $ destinationPath = $ source -> getPath ( ) ; $ sourcePath = $ source -> getPath ( $ this -> request -> from ) ; $ this -> accessControl -> checkPermission ( $ this -> getUserRole ( ) , $ this -> action , $ destinationPath ) ; $ this -> accessControl -> checkPermission ( $ this -> getUserRole ( ) , $ this -> action , $ sourcePath ) ; if ( $ sourcePath ) { if ( $ destinationPath ) { if ( is_file ( $ sourcePath ) or is_dir ( $ sourcePath ) ) { rename ( $ sourcePath , $ destinationPath . basename ( $ sourcePath ) ) ; } else { throw new \ Exception ( 'Not file' , Consts :: ERROR_CODE_NOT_EXISTS ) ; } } else { throw new \ Exception ( 'Need destination path' , Consts :: ERROR_CODE_BAD_REQUEST ) ; } } else { throw new \ Exception ( 'Need source path' , Consts :: ERROR_CODE_BAD_REQUEST ) ; } } | Move file or directory to another folder |
19,605 | public function actionGetLocalFileByUrl ( ) { $ url = $ this -> request -> url ; if ( ! $ url ) { throw new \ Exception ( 'Need full url' , Consts :: ERROR_CODE_BAD_REQUEST ) ; } $ parts = parse_url ( $ url ) ; if ( empty ( $ parts [ 'path' ] ) ) { throw new \ Exception ( 'Empty url' , Consts :: ERROR_CODE_BAD_REQUEST ) ; } $ found = false ; $ path = '' ; $ root = '' ; $ key = 0 ; foreach ( $ this -> config -> sources as $ key => $ source ) { if ( $ this -> request -> source && $ this -> request -> source !== 'default' && $ key !== $ this -> request -> source && $ this -> request -> path !== './' ) { continue ; } $ base = parse_url ( $ source -> baseurl ) ; $ path = preg_replace ( '#^(/)?' . $ base [ 'path' ] . '#' , '' , $ parts [ 'path' ] ) ; $ root = $ source -> getPath ( ) ; if ( file_exists ( $ root . $ path ) && is_file ( $ root . $ path ) ) { $ file = new File ( $ root . $ path ) ; if ( $ file -> isGoodFile ( $ source ) ) { $ found = true ; break ; } } } if ( ! $ found ) { throw new \ Exception ( 'File does not exist or is above the root of the connector' , Consts :: ERROR_CODE_FAILED ) ; } return [ 'path' => str_replace ( $ root , '' , dirname ( $ root . $ path ) . Consts :: DS ) , 'name' => basename ( $ path ) , 'source' => $ key ] ; } | Get filepath by URL for local files |
19,606 | public function getSource ( $ context = null ) { $ class = static :: class ; return Text :: underscore ( ( $ pos = strrpos ( $ class , '\\' ) ) === false ? $ class : substr ( $ class , $ pos + 1 ) ) ; } | Returns table name mapped in the model |
19,607 | public static function last ( $ filters = null , $ fields = null ) { $ model = new static ( ) ; if ( is_string ( $ primaryKey = $ model -> getPrimaryKey ( ) ) ) { $ options [ 'order' ] = [ $ primaryKey => SORT_DESC ] ; } else { throw new BadMethodCallException ( 'infer `:class` order condition for last failed:' , [ 'class' => static :: class ] ) ; } $ rs = static :: query ( null , $ model ) -> select ( $ fields ) -> where ( $ filters ) -> limit ( 1 ) -> fetch ( ) ; return isset ( $ rs [ 0 ] ) ? $ rs [ 0 ] : null ; } | Allows to query the last record that match the specified conditions |
19,608 | public static function avg ( $ field , $ filters = null ) { return ( float ) static :: query ( ) -> where ( $ filters ) -> avg ( $ field ) ; } | Allows to calculate the average value on a column matching the specified conditions |
19,609 | public function assign ( $ data , $ whiteList = null ) { if ( $ whiteList === null ) { $ whiteList = $ this -> getSafeFields ( ) ; } if ( $ whiteList === null ) { throw new PreconditionException ( [ '`:model` model do not define accessible fields.' , 'model' => static :: class ] ) ; } foreach ( $ whiteList ? : $ this -> getFields ( ) as $ field ) { if ( isset ( $ data [ $ field ] ) ) { $ value = $ data [ $ field ] ; $ this -> { $ field } = is_string ( $ value ) ? trim ( $ value ) : $ value ; } } return $ this ; } | Assigns values to a model from an array |
19,610 | public function delete ( ) { $ this -> eventsManager -> fireEvent ( 'model:beforeDelete' , $ this ) ; static :: query ( null , $ this ) -> where ( $ this -> _getPrimaryKeyValuePairs ( ) ) -> delete ( ) ; $ this -> eventsManager -> fireEvent ( 'model:afterDelete' , $ this ) ; return $ this ; } | Deletes a model instance . Returning true on success or false otherwise . |
19,611 | public function toArray ( ) { $ data = [ ] ; foreach ( get_object_vars ( $ this ) as $ field => $ value ) { if ( $ field [ 0 ] === '_' ) { continue ; } if ( is_object ( $ value ) ) { if ( $ value instanceof self ) { $ value = $ value -> toArray ( ) ; } else { continue ; } } elseif ( is_array ( $ value ) && ( $ first = current ( $ value ) ) && $ first instanceof self ) { foreach ( $ value as $ k => $ v ) { $ value [ $ k ] = $ v -> toArray ( ) ; } } if ( $ value !== null ) { $ data [ $ field ] = $ value ; } } return $ data ; } | Returns the instance as an array representation |
19,612 | public function getChangedFields ( ) { if ( $ this -> _snapshot === false ) { throw new PreconditionException ( [ 'getChangedFields failed: `:model` instance is snapshot disabled' , 'model' => static :: class ] ) ; } $ changed = [ ] ; foreach ( $ this -> getFields ( ) as $ field ) { if ( isset ( $ this -> _snapshot [ $ field ] ) ) { if ( $ this -> { $ field } !== $ this -> _snapshot [ $ field ] ) { $ changed [ ] = $ field ; } } elseif ( $ this -> $ field !== null ) { $ changed [ ] = $ field ; } } return $ changed ; } | Returns a list of changed values |
19,613 | public function hasChanged ( $ fields ) { if ( $ this -> _snapshot === false ) { throw new PreconditionException ( [ 'getChangedFields failed: `:model` instance is snapshot disabled' , 'model' => static :: class ] ) ; } foreach ( ( array ) $ fields as $ field ) { if ( ! isset ( $ this -> _snapshot [ $ field ] ) || $ this -> { $ field } !== $ this -> _snapshot [ $ field ] ) { return true ; } } return false ; } | Check if a specific attribute has changed This only works if the model is keeping data snapshots |
19,614 | public function hasRole ( $ role = "general" ) { $ roleModel = new \ erdiko \ users \ models \ Role ; $ roleEntity = $ roleModel -> findByName ( $ role ) ; if ( empty ( $ roleEntity ) ) { throw new \ Exception ( "Error, role {$role} not found." ) ; } $ result = $ this -> _user -> getRole ( ) == $ roleEntity -> getId ( ) ; return $ result ; } | hasRole returns true if current user has requested role |
19,615 | public function save ( $ data = array ( ) ) { if ( empty ( $ data ) ) { throw new \ Exception ( "User data is missing" ) ; } $ data = ( object ) $ data ; if ( ( ! isset ( $ data -> email ) || empty ( $ data -> email ) ) ) { throw new \ Exception ( "Email is required" ) ; } if ( ( ! isset ( $ data -> password ) || empty ( $ data -> password ) ) && ! isset ( $ data -> id ) ) { throw new \ Exception ( "Password is required" ) ; } $ new = false ; if ( isset ( $ data -> id ) ) { $ entity = $ this -> getById ( $ data -> id ) ; } else { $ entity = new entity ( ) ; $ new = true ; } if ( isset ( $ data -> name ) ) { $ entity -> setName ( $ data -> name ) ; } if ( isset ( $ data -> email ) ) { $ entity -> setEmail ( $ data -> email ) ; } if ( isset ( $ data -> password ) ) { $ entity -> setPassword ( $ this -> getSalted ( $ data -> password ) ) ; } elseif ( isset ( $ data -> new_password ) ) { $ entity -> setPassword ( $ this -> getSalted ( $ data -> new_password ) ) ; } if ( empty ( $ data -> role ) ) { $ data -> role = $ this -> _getDefaultRole ( ) ; } $ entity -> setRole ( $ data -> role ) ; if ( isset ( $ data -> gateway_customer_id ) ) { $ entity -> setGatewayCustomerId ( $ data -> gateway_customer_id ) ; } if ( $ new ) { $ this -> _em -> persist ( $ entity ) ; } else { $ this -> _em -> merge ( $ entity ) ; } try { $ eventType = $ new ? Log :: EVENT_CREATE : Log :: EVENT_UPDATE ; if ( isset ( $ data -> new_password ) ) { $ eventType = Log :: EVENT_PASSWORD ; unset ( $ data -> new_password ) ; } unset ( $ data -> password ) ; $ this -> createUserEventLog ( $ eventType , $ data ) ; $ this -> _em -> flush ( ) ; $ this -> setEntity ( $ entity ) ; return $ entity -> getId ( ) ; } catch ( \ Doctrine \ DBAL \ Exception \ UniqueConstraintViolationException $ e ) { throw new \ Exception ( "Can not create user with duplicate email" ) ; } return null ; } | Update or create a new user |
19,616 | public function create ( ) { $ autoIncrementField = $ this -> getAutoIncrementField ( ) ; if ( $ autoIncrementField && $ this -> $ autoIncrementField === null ) { $ this -> $ autoIncrementField = $ this -> getNextAutoIncrementId ( ) ; } $ fields = $ this -> getFields ( ) ; foreach ( $ this -> getAutoFilledData ( self :: OP_CREATE ) as $ field => $ value ) { if ( ! in_array ( $ field , $ fields , true ) || $ this -> $ field !== null ) { continue ; } $ this -> $ field = $ value ; } $ this -> validate ( $ fields ) ; $ this -> eventsManager -> fireEvent ( 'model:beforeSave' , $ this ) ; $ this -> eventsManager -> fireEvent ( 'model:beforeCreate' , $ this ) ; $ fieldValues = [ ] ; $ defaultValueFields = [ ] ; foreach ( $ fields as $ field ) { if ( $ this -> $ field !== null ) { $ fieldValues [ $ field ] = $ this -> $ field ; } elseif ( $ field !== $ autoIncrementField ) { $ defaultValueFields [ ] = $ field ; } } foreach ( $ this -> getJsonFields ( ) as $ field ) { if ( is_array ( $ this -> $ field ) ) { $ fieldValues [ $ field ] = json_encode ( $ this -> $ field , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) ; } } $ connection = $ this -> _di -> getShared ( $ this -> getDb ( $ this ) ) ; if ( $ autoIncrementField && $ this -> $ autoIncrementField === null ) { $ this -> $ autoIncrementField = ( int ) $ connection -> insert ( $ this -> getSource ( $ this ) , $ fieldValues , true ) ; } else { $ connection -> insert ( $ this -> getSource ( $ this ) , $ fieldValues ) ; } if ( $ defaultValueFields ) { if ( $ r = static :: query ( null , $ this ) -> select ( $ defaultValueFields ) -> where ( $ this -> _getPrimaryKeyValuePairs ( ) ) -> fetch ( true ) ) { foreach ( $ r [ 0 ] as $ field => $ value ) { $ this -> $ field = $ value ; } } } $ this -> _snapshot = $ this -> toArray ( ) ; $ this -> eventsManager -> fireEvent ( 'model:afterCreate' , $ this ) ; $ this -> eventsManager -> fireEvent ( 'model:afterSave' , $ this ) ; return $ this ; } | Inserts a model instance . If the instance already exists in the persistence it will throw an exception |
19,617 | protected function checkAuth ( ) { try { list ( $ jwt ) = sscanf ( $ _SERVER [ "HTTP_AUTHORIZATION" ] , 'Bearer %s' ) ; $ authenticator = new JWTAuthenticator ( new User ( ) ) ; $ config = \ Erdiko :: getConfig ( ) ; $ secretKey = $ config [ "site" ] [ "secret_key" ] ; $ params = array ( 'secret_key' => $ secretKey , 'jwt' => $ jwt ) ; $ user = $ authenticator -> verify ( $ params , 'jwt_auth' ) ; return true ; } catch ( \ Exception $ e ) { return true ; } } | It always returns true because login is not a must in this section but we still want to create authenticator instance if there s a logged in user to restrict some actions . |
19,618 | public function setShutdownWithoutResponse ( $ value , $ customeExceptionMessage = null ) { $ this -> shutdownWithoutResponse = $ value ; $ this -> customeExceptionMessage = $ customeExceptionMessage ; return $ this ; } | If no response provided Exception of type CrudGenerator \ Generators \ ResponseExpectedException will be throw |
19,619 | protected function getTaskRequest ( $ id ) { if ( $ id === null ) { throw new \ InvalidArgumentException ( 'Missing the required parameter $id when calling getTask' ) ; } $ resourcePath = '/tasks/{id}' ; $ formParams = [ ] ; $ queryParams = [ ] ; $ headerParams = [ ] ; $ httpBody = '' ; $ multipart = false ; if ( $ id !== null ) { $ resourcePath = str_replace ( '{' . 'id' . '}' , ObjectSerializer :: toPathValue ( $ id ) , $ resourcePath ) ; } $ _tempBody = null ; if ( $ multipart ) { $ headers = $ this -> headerSelector -> selectHeadersForMultipart ( [ 'application/json' ] ) ; } else { $ headers = $ this -> headerSelector -> selectHeaders ( [ 'application/json' ] , [ 'application/json' ] ) ; } if ( isset ( $ _tempBody ) ) { $ httpBody = $ _tempBody ; if ( $ httpBody instanceof \ stdClass && $ headers [ 'Content-Type' ] === 'application/json' ) { $ httpBody = \ GuzzleHttp \ json_encode ( $ httpBody ) ; } } elseif ( count ( $ formParams ) > 0 ) { if ( $ multipart ) { $ multipartContents = [ ] ; foreach ( $ formParams as $ formParamName => $ formParamValue ) { $ multipartContents [ ] = [ 'name' => $ formParamName , 'contents' => $ formParamValue ] ; } $ httpBody = new MultipartStream ( $ multipartContents ) ; } elseif ( $ headers [ 'Content-Type' ] === 'application/json' ) { $ httpBody = \ GuzzleHttp \ json_encode ( $ formParams ) ; } else { $ httpBody = \ GuzzleHttp \ Psr7 \ build_query ( $ formParams ) ; } } $ apiKey = $ this -> config -> getApiKeyWithPrefix ( 'X-API-KEY' ) ; if ( $ apiKey !== null ) { $ headers [ 'X-API-KEY' ] = $ apiKey ; } $ defaultHeaders = [ ] ; if ( $ this -> config -> getUserAgent ( ) ) { $ defaultHeaders [ 'User-Agent' ] = $ this -> config -> getUserAgent ( ) ; } $ headers = array_merge ( $ defaultHeaders , $ headerParams , $ headers ) ; $ query = \ GuzzleHttp \ Psr7 \ build_query ( $ queryParams ) ; return new Request ( 'GET' , $ this -> config -> getHost ( ) . $ resourcePath . ( $ query ? "?{$query}" : '' ) , $ headers , $ httpBody ) ; } | Create request for operation getTask |
19,620 | public function nodeAction ( ) { FrontController :: getInstance ( ) -> getView ( ) -> setLayoutDisabled ( ) ; $ this -> view -> parentId = ( $ this -> parentId > 0 ) ? $ this -> parentId : null ; $ this -> view -> categoryTree = ( new \ Cms \ Model \ CategoryModel ) -> getCategoryTree ( $ this -> view -> parentId ) ; } | Renderowanie fragmentu drzewa stron na podstawie parentId |
19,621 | public function createAction ( ) { $ this -> getResponse ( ) -> setTypeJson ( ) ; $ cat = new \ Cms \ Orm \ CmsCategoryRecord ( ) ; $ cat -> name = $ this -> getPost ( ) -> name ; $ cat -> parentId = ( $ this -> getPost ( ) -> parentId > 0 ) ? $ this -> getPost ( ) -> parentId : null ; $ cat -> order = $ this -> getPost ( ) -> order ; $ cat -> active = false ; $ cat -> status = \ Cms \ Orm \ CmsCategoryRecord :: STATUS_ACTIVE ; if ( $ cat -> save ( ) ) { $ icon = '' ; $ disabled = false ; if ( ! $ cat -> active ) { $ icon = $ this -> view -> baseUrl . '/resource/cmsAdmin/images/folder-inactive.png' ; } $ acl = ( new \ CmsAdmin \ Model \ CategoryAclModel ) -> getAcl ( ) ; if ( ! $ acl -> isAllowed ( \ App \ Registry :: $ auth -> getRoles ( ) , $ cat -> id ) ) { $ disabled = true ; $ icon = $ this -> view -> baseUrl . '/resource/cmsAdmin/images/folder-disabled.png' ; } return json_encode ( [ 'status' => true , 'id' => $ cat -> id , 'icon' => $ icon , 'disabled' => $ disabled , 'message' => $ this -> view -> _ ( 'controller.category.create.message' ) ] ) ; } return json_encode ( [ 'status' => false , 'error' => $ this -> view -> _ ( 'controller.category.create.error' ) ] ) ; } | Tworzenie nowej strony |
19,622 | public function renameAction ( ) { $ this -> getResponse ( ) -> setTypeJson ( ) ; if ( null !== $ cat = ( new \ Cms \ Orm \ CmsCategoryQuery ) -> findPk ( $ this -> getPost ( ) -> id ) ) { $ name = trim ( $ this -> getPost ( ) -> name ) ; if ( mb_strlen ( $ name ) < 2 || mb_strlen ( $ name ) > 64 ) { return json_encode ( [ 'status' => false , 'error' => $ this -> view -> _ ( 'controller.category.rename.validator' ) ] ) ; } $ cat -> name = $ name ; if ( $ cat -> save ( ) ) { return json_encode ( [ 'status' => true , 'id' => $ cat -> id , 'name' => $ name , 'message' => $ this -> view -> _ ( 'controller.category.rename.message' ) ] ) ; } } return json_encode ( [ 'status' => false , 'error' => $ this -> view -> _ ( 'controller.category.rename.error' ) ] ) ; } | Zmiana nazwy strony |
19,623 | public function moveAction ( ) { $ this -> getResponse ( ) -> setTypeJson ( ) ; if ( null === $ masterCategory = ( new \ Cms \ Orm \ CmsCategoryQuery ) -> findPk ( $ this -> getPost ( ) -> id ) ) { return json_encode ( [ 'status' => false , 'error' => $ this -> view -> _ ( 'controller.category.move.error.missing' ) ] ) ; } $ draft = $ masterCategory ; if ( $ this -> getPost ( ) -> parentId != $ masterCategory -> parentId ) { $ draft = ( new \ Cms \ Model \ CategoryDraft ( $ masterCategory ) ) -> createAndGetDraftForUser ( \ App \ Registry :: $ auth -> getId ( ) , true ) ; } $ draft -> parentId = ( $ this -> getPost ( ) -> parentId > 0 ) ? $ this -> getPost ( ) -> parentId : null ; $ draft -> order = $ this -> getPost ( ) -> order ; return ( $ draft -> save ( ) && $ draft -> commitVersion ( ) ) ? json_encode ( [ 'status' => true , 'id' => $ masterCategory -> id , 'message' => $ this -> view -> _ ( 'controller.category.move.message' ) ] ) : json_encode ( [ 'status' => false , 'error' => $ this -> view -> _ ( 'controller.category.move.error' ) ] ) ; } | Przenoszenie strony w drzewie |
19,624 | public function copyAction ( ) { $ this -> getResponse ( ) -> setTypeJson ( ) ; if ( null === $ category = ( new \ Cms \ Orm \ CmsCategoryQuery ) -> findPk ( $ this -> getPost ( ) -> id ) ) { return json_encode ( [ 'status' => false , 'error' => 'Strona nie istnieje' ] ) ; } $ copyModel = new \ Cms \ Model \ CategoryCopy ( $ category ) ; if ( $ copyModel -> copyWithTransaction ( ) ) { return json_encode ( [ 'status' => true , 'id' => $ copyModel -> getCopyRecord ( ) -> id , 'message' => $ this -> view -> _ ( 'controller.category.copy.message' ) ] ) ; } return json_encode ( [ 'status' => false , 'error' => $ this -> view -> _ ( 'controller.category.copy.error' ) ] ) ; } | Kopiowanie strony - kategorii |
19,625 | private function _isCategoryDuplicate ( $ originalId ) { $ category = ( new \ Cms \ Orm \ CmsCategoryQuery ) -> findPk ( $ originalId ) ; return ( null !== ( new \ Cms \ Orm \ CmsCategoryQuery ) -> whereId ( ) -> notEquals ( $ category -> id ) -> andFieldRedirectUri ( ) -> equals ( null ) -> andFieldStatus ( ) -> equals ( \ Cms \ Orm \ CmsCategoryRecord :: STATUS_ACTIVE ) -> andQuery ( ( new \ Cms \ Orm \ CmsCategoryQuery ) -> searchByUri ( $ category -> uri ) ) -> findFirst ( ) ) && ! $ category -> redirectUri && ! $ category -> customUri ; } | Sprawdzanie czy kategoria ma duplikat |
19,626 | private function _setReferrer ( $ referer , $ id ) { if ( ! $ referer || strpos ( $ referer , self :: EDIT_MVC_PARAMS ) ) { return ; } if ( strpos ( $ referer , 'cms-content-preview' ) ) { return ; } $ space = new \ Mmi \ Session \ SessionSpace ( self :: SESSION_SPACE_PREFIX . $ id ) ; $ space -> referer = $ referer ; } | Ustawianie referer a do sesji |
19,627 | public function findSent ( User $ user , $ executeQuery = true ) { $ dql = " SELECT um, m, u FROM Claroline\MessageBundle\Entity\UserMessage um JOIN um.user u JOIN um.message m WHERE u.id = {$user->getId()} AND um.isRemoved = false AND um.isSent = true ORDER BY m.date DESC " ; $ query = $ this -> _em -> createQuery ( $ dql ) ; return $ executeQuery ? $ query -> getResult ( ) : $ query ; } | Finds UserMessage marked as sent by a user . |
19,628 | public function findReceivedByObjectOrSender ( User $ receiver , $ objectOrSenderUsernameSearch , $ executeQuery = true ) { $ dql = " SELECT um, m, u FROM Claroline\MessageBundle\Entity\UserMessage um JOIN um.user u JOIN um.message m WHERE u.id = {$receiver->getId()} AND um.isRemoved = false AND um.isSent = false AND ( UPPER(m.object) LIKE :search OR UPPER(m.senderUsername) LIKE :search ) ORDER BY m.date DESC " ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ searchParameter = '%' . strtoupper ( $ objectOrSenderUsernameSearch ) . '%' ; $ query -> setParameter ( 'search' , $ searchParameter ) ; return $ executeQuery ? $ query -> getResult ( ) : $ query ; } | Finds UserMessage received by a user filtered by a search on the object or on the username of the sender . |
19,629 | public function findSentByObject ( User $ sender , $ objectSearch , $ executeQuery = true ) { $ dql = " SELECT um, m, u FROM Claroline\MessageBundle\Entity\UserMessage um JOIN um.user u JOIN um.message m WHERE u.id = {$sender->getId()} AND um.isRemoved = false AND um.isSent = true AND UPPER(m.object) LIKE :search ORDER BY m.date DESC " ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ searchParameter = '%' . strtoupper ( $ objectSearch ) . '%' ; $ query -> setParameter ( 'search' , $ searchParameter ) ; return $ executeQuery ? $ query -> getResult ( ) : $ query ; } | Finds UserMessage sent by a user filtered by a search on the object . |
19,630 | public function findRemovedByObjectOrSender ( User $ user , $ objectOrSenderUsernameSearch , $ executeQuery = true ) { $ dql = " SELECT um, m, u FROM Claroline\MessageBundle\Entity\UserMessage um JOIN um.user u JOIN um.message m WHERE u.id = {$user->getId()} AND um.isRemoved = true AND ( UPPER(m.object) LIKE :search OR UPPER(m.senderUsername) LIKE :search ) GROUP BY m ORDER BY m.date DESC " ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ searchParameter = '%' . strtoupper ( $ objectOrSenderUsernameSearch ) . '%' ; $ query -> setParameter ( 'search' , $ searchParameter ) ; return $ executeQuery ? $ query -> getResult ( ) : $ query ; } | Finds UserMessage removed by a user filtered by a search on the object or on the username of the sender . |
19,631 | public function findByMessages ( User $ user , array $ messages ) { $ messageIds = array ( ) ; foreach ( $ messages as $ message ) { $ messageIds [ ] = $ message -> getId ( ) ; } $ dql = ' SELECT um FROM Claroline\MessageBundle\Entity\UserMessage um JOIN um.user u JOIN um.message m WHERE m.id IN (:messageIds) AND u.id = :userId ORDER BY m.date DESC ' ; $ query = $ this -> _em -> createQuery ( $ dql ) ; $ query -> setParameter ( 'messageIds' , $ messageIds ) ; $ query -> setParameter ( 'userId' , $ user -> getId ( ) ) ; return $ query -> getResult ( ) ; } | Finds UserMessage received or sent by a user filtered by specific messages . |
19,632 | public static function getUniqueObjects ( ) { $ all = ( new Orm \ CmsStatDateQuery ) -> whereHour ( ) -> equals ( null ) -> andFieldDay ( ) -> equals ( null ) -> andFieldMonth ( ) -> equals ( null ) -> andFieldObjectId ( ) -> equals ( null ) -> orderAscObject ( ) -> find ( ) ; $ objects = [ ] ; foreach ( $ all as $ object ) { if ( ! isset ( $ objects [ $ object -> object ] ) ) { $ objects [ $ object -> object ] = $ object -> object ; } } return $ objects ; } | Pobiera unikalne obiekty |
19,633 | public static function getRows ( $ object , $ objectId , $ year = null , $ month = null , $ day = null , $ hour = null ) { $ q = ( new Orm \ CmsStatDateQuery ) -> whereObject ( ) -> equals ( $ object ) -> andFieldObjectId ( ) -> equals ( $ objectId ) ; self :: _bindParam ( $ q , 'year' , $ year ) ; self :: _bindParam ( $ q , 'month' , $ month ) ; self :: _bindParam ( $ q , 'day' , $ day ) ; self :: _bindParam ( $ q , 'hour' , $ hour ) ; return $ q -> orderAsc ( 'day' ) -> orderAsc ( 'month' ) -> orderAsc ( 'year' ) -> orderAsc ( 'hour' ) -> find ( ) ; } | Pobranie wierszy z DB |
19,634 | private function buildKey ( $ userObject ) { $ key = $ this -> classMetadata -> getPropertyValue ( $ userObject , ClassMetadata :: API_KEY_PROPERTY ) ; if ( empty ( $ key ) ) { $ this -> classMetadata -> modifyProperty ( $ userObject , $ this -> keyFactory -> getKey ( ) , ClassMetadata :: API_KEY_PROPERTY ) ; } } | Simple helper which builds the API key and stores it in the user . |
19,635 | private function resolveObject ( $ loginProperty , array $ credentials ) { return $ this -> om -> getRepository ( $ this -> modelName ) -> findOneBy ( [ $ loginProperty => $ credentials [ $ loginProperty ] , ] ) ; } | Simple helper which searches the ObjectManager by the given login parameter . |
19,636 | private function validateCredentials ( $ object , $ password ) { return ! ( null === $ object || ! $ this -> passwordHasher -> compareWith ( $ object -> getPassword ( ) , $ password ) ) ; } | Validates the existance of the object and ensures that a valid password is given . |
19,637 | private function buildEventObject ( $ user , $ purgeJob = false ) { $ event = new OnLogoutEvent ( $ user ) ; if ( $ purgeJob ) { $ event -> markAsPurgeJob ( ) ; } return $ event ; } | Builds the OnLogoutEvent . |
19,638 | private function fill ( array $ args ) { $ properties = array_keys ( get_object_vars ( $ this ) ) ; foreach ( $ args as $ key => $ value ) { if ( in_array ( $ key , $ properties ) ) { $ this -> { $ key } = $ value ; } } } | Fill the object |
19,639 | public function getUrl ( $ https = null ) { return \ Mmi \ App \ FrontController :: getInstance ( ) -> getView ( ) -> url ( [ 'module' => 'cms' , 'controller' => 'category' , 'action' => 'dispatch' , 'uri' => $ this -> customUri ? $ this -> customUri : $ this -> uri ] , true , $ https ) ; } | Pobiera url kategorii |
19,640 | public function getParentRecord ( ) { if ( ! $ this -> parentId ) { return ; } if ( null === $ parent = \ App \ Registry :: $ cache -> load ( $ cacheKey = 'category-' . $ this -> parentId ) ) { \ App \ Registry :: $ cache -> save ( $ parent = ( new \ Cms \ Orm \ CmsCategoryQuery ) -> withType ( ) -> findPk ( $ this -> parentId ) , $ cacheKey , 0 ) ; } return $ parent ; } | Pobiera rekord rodzica |
19,641 | protected function _getChildren ( $ parentId , $ activeOnly = false ) { $ query = ( new CmsCategoryQuery ) -> whereParentId ( ) -> equals ( $ parentId ) -> joinLeft ( 'cms_category_type' ) -> on ( 'cms_category_type_id' ) -> orderAscOrder ( ) -> orderAscId ( ) ; if ( $ activeOnly ) { $ query -> whereStatus ( ) -> equals ( self :: STATUS_ACTIVE ) ; } return $ query -> find ( ) -> toObjectArray ( ) ; } | Zwraca dzieci danego rodzica |
19,642 | protected function _sortChildren ( ) { $ i = 0 ; foreach ( $ this -> _getChildren ( $ this -> parentId , true ) as $ categoryRecord ) { if ( $ categoryRecord -> id == $ this -> id ) { continue ; } if ( $ this -> order == $ i ) { $ i ++ ; } $ categoryRecord -> order = $ i ++ ; $ categoryRecord -> setOption ( 'block-ordering' , true ) -> save ( ) ; } } | Sortuje dzieci wybranego rodzica |
19,643 | private function searchUsers ( ) { $ criteria = Criteria :: create ( ) -> where ( Criteria :: expr ( ) -> lte ( $ this -> classMetadata -> getPropertyName ( ClassMetadata :: LAST_ACTION_PROPERTY ) , new \ DateTime ( $ this -> dateTimeRule ) ) ) -> andWhere ( Criteria :: expr ( ) -> neq ( $ this -> classMetadata -> getPropertyName ( ClassMetadata :: API_KEY_PROPERTY ) , null ) ) ; return $ this -> getUsersByCriteria ( $ criteria ) ; } | Search query for users with outdated api keys . |
19,644 | private function getUsersByCriteria ( Criteria $ criteria ) { $ repository = $ this -> om -> getRepository ( $ this -> modelName ) ; if ( $ repository instanceof Selectable ) { $ filteredUsers = $ repository -> matching ( $ criteria ) ; } else { $ allUsers = new ArrayCollection ( $ repository -> findAll ( ) ) ; $ filteredUsers = $ allUsers -> matching ( $ criteria ) ; } return $ filteredUsers -> toArray ( ) ; } | Simple utility to query users by a given criteria . |
19,645 | private static function _extractBytes ( $ byteString , $ start , $ length ) { if ( function_exists ( 'mb_substr' ) ) { return mb_substr ( $ byteString , $ start , $ length , '8bit' ) ; } return substr ( $ byteString , $ start , $ length ) ; } | Returns the bytes of the given string specified by the start and length parameters . |
19,646 | private static function _intStrToByteStr ( $ intStr ) { if ( ! preg_match ( '/[0-9]+/' , ( string ) $ intStr ) ) { $ msg = 'Argument 1 must be a non-negative integer or a string representing a non-negative integer.' ; throw new InvalidArgumentException ( $ msg , self :: E_NO_NON_NEGATIVE_INT ) ; } $ byteStr = '' ; $ int = ( int ) $ intStr ; if ( ( string ) $ int == ( string ) $ intStr ) { while ( $ int > 0 ) { $ byteStr = chr ( $ int & 255 ) . $ byteStr ; $ int >>= 8 ; } } else { if ( extension_loaded ( 'bcmath' ) ) { while ( ( int ) $ intStr > 0 ) { $ byteStr = chr ( bcmod ( $ intStr , '256' ) ) . $ byteStr ; $ intStr = bcdiv ( $ intStr , '256' , 0 ) ; } } else { throw new RuntimeException ( 'BC Math functions are not available.' , self :: E_NO_BCMATH ) ; } } if ( $ byteStr == '' ) $ byteStr = chr ( 0 ) ; return $ byteStr ; } | Converts an integer into a byte - string . |
19,647 | private static function _byteStrToIntStr ( $ byteStr ) { $ byteCount = self :: _byteCount ( $ byteStr ) ; if ( $ byteCount == 0 ) { $ msg = 'Empty byte-string cannot be convertet to integer.' ; throw new InvalidArgumentException ( $ msg , self :: E_EMPTY_BYTESTRING ) ; } if ( $ byteCount <= PHP_INT_SIZE ) { $ int = 0 ; for ( $ i = 0 ; $ i < $ byteCount ; $ i ++ ) { $ int <<= 8 ; $ int |= ord ( $ byteStr [ $ i ] ) ; } if ( $ int >= 0 ) return $ int ; } if ( extension_loaded ( 'bcmath' ) ) { $ intStr = '0' ; for ( $ i = 0 ; $ i < $ byteCount ; $ i ++ ) { $ intStr = bcmul ( $ intStr , '256' , 0 ) ; $ intStr = bcadd ( $ intStr , ( string ) ord ( $ byteStr [ $ i ] ) , 0 ) ; } return $ intStr ; } else { throw new RuntimeException ( 'BC Math functions are not available.' , self :: E_NO_BCMATH ) ; } } | Converts a byte - string into a non - negative integer . |
19,648 | private static function _intStrModulus ( $ intStr , $ divisor ) { $ int = ( int ) $ intStr ; if ( ( string ) $ int == ( string ) $ intStr ) { return $ int % $ divisor ; } else { if ( extension_loaded ( 'bcmath' ) ) { return bcmod ( $ intStr , ( string ) $ divisor ) ; } else { throw new RuntimeException ( 'BC Math functions are not available.' , self :: E_NO_BCMATH ) ; } } } | Calculates dividend modulus divisor . |
19,649 | private static function _encodeByteStr ( $ byteStr , $ alphabet , $ pad ) { if ( ! is_string ( $ byteStr ) ) { $ msg = 'Supplied argument 1 is not a string.' ; throw new InvalidArgumentException ( $ msg , self :: E_NO_STRING ) ; } $ byteCount = self :: _byteCount ( $ byteStr ) ; $ remainder = $ byteCount % 5 ; $ fillbyteCount = ( $ remainder ) ? 5 - $ remainder : 0 ; if ( $ fillbyteCount > 0 ) $ byteStr .= str_repeat ( chr ( 0 ) , $ fillbyteCount ) ; $ encodedStr = '' ; for ( $ i = 0 ; $ i < ( $ byteCount + $ fillbyteCount ) ; $ i = $ i + 5 ) { $ byte1 = ord ( $ byteStr [ $ i ] ) ; $ byte2 = ord ( $ byteStr [ $ i + 1 ] ) ; $ byte3 = ord ( $ byteStr [ $ i + 2 ] ) ; $ byte4 = ord ( $ byteStr [ $ i + 3 ] ) ; $ byte5 = ord ( $ byteStr [ $ i + 4 ] ) ; $ bitGroup = $ byte1 >> 3 ; $ encodedStr .= $ alphabet [ $ bitGroup ] ; $ bitGroup = ( $ byte1 & ~ ( 31 << 3 ) ) << 2 | $ byte2 >> 6 ; $ encodedStr .= $ alphabet [ $ bitGroup ] ; $ bitGroup = $ byte2 >> 1 & ~ ( 3 << 5 ) ; $ encodedStr .= $ alphabet [ $ bitGroup ] ; $ bitGroup = ( $ byte2 & 1 ) << 4 | $ byte3 >> 4 ; $ encodedStr .= $ alphabet [ $ bitGroup ] ; $ bitGroup = ( $ byte3 & ~ ( 15 << 4 ) ) << 1 | $ byte4 >> 7 ; $ encodedStr .= $ alphabet [ $ bitGroup ] ; $ bitGroup = $ byte4 >> 2 & ~ ( 1 << 5 ) ; $ encodedStr .= $ alphabet [ $ bitGroup ] ; $ bitGroup = ( $ byte4 & ~ ( 63 << 2 ) ) << 3 | $ byte5 >> 5 ; $ encodedStr .= $ alphabet [ $ bitGroup ] ; $ bitGroup = $ byte5 & ~ ( 7 << 5 ) ; $ encodedStr .= $ alphabet [ $ bitGroup ] ; } $ encodedStrLen = ( $ byteCount + $ fillbyteCount ) * 8 / 5 ; $ fillbitCharCount = ( int ) ( $ fillbyteCount * 8 / 5 ) ; $ encodedStr = substr ( $ encodedStr , 0 , $ encodedStrLen - $ fillbitCharCount ) ; if ( $ pad ) $ encodedStr .= str_repeat ( $ alphabet [ 32 ] , $ fillbitCharCount ) ; return $ encodedStr ; } | Base 32 encodes the given byte - string using the given alphabet . |
19,650 | public static function decodeToByteStr ( $ encodedStr , $ allowOmittedPadding = false ) { $ pattern = '/[A-Z2-7]*([A-Z2-7]={0,6})?/' ; self :: _checkEncodedString ( $ encodedStr , $ pattern ) ; $ encodedStrLen = self :: _byteCount ( $ encodedStr ) ; $ byteStr = self :: _decodeToByteStr ( $ encodedStr , $ encodedStrLen , self :: $ _commonFlippedAlphabet , '=' , $ allowOmittedPadding ) ; return $ byteStr ; } | Decodes a RFC 4646 base32 encoded string to a byte - string . |
19,651 | public static function decodeHexToByteStr ( $ encodedStr , $ allowOmittedPadding = false ) { $ pattern = '/[0-9A-V]*([0-9A-V]={0,6})?/' ; self :: _checkEncodedString ( $ encodedStr , $ pattern ) ; $ encodedStrLen = self :: _byteCount ( $ encodedStr ) ; $ byteStr = self :: _decodeToByteStr ( $ encodedStr , $ encodedStrLen , self :: $ _hexFlippedAlphabet , '=' , $ allowOmittedPadding ) ; return $ byteStr ; } | Decodes a RFC 4646 base32 extended hex encoded string to a byte - string . |
19,652 | private static function _decodeCrockford ( $ to , $ encodedStr , $ hasCheckSymbol = false ) { if ( $ hasCheckSymbol ) { $ pattern = '/[0-9A-TV-Z-]*[0-9A-Z*~$=]-*/i' ; } else { $ pattern = '/[0-9A-TV-Z-]*/i' ; } self :: _checkEncodedString ( $ encodedStr , $ pattern ) ; $ encodedStr = str_replace ( '-' , '' , $ encodedStr ) ; $ encodedStrLen = self :: _byteCount ( $ encodedStr ) ; if ( $ hasCheckSymbol ) { $ checkSymbol = $ encodedStr [ $ encodedStrLen - 1 ] ; $ encodedStr = self :: _extractBytes ( $ encodedStr , 0 , $ encodedStrLen - 1 ) ; $ encodedStrLen -- ; } $ mapping = self :: $ _crockfordFlippedAlphabet + self :: $ _crockfordAdditionalCharMapping + array ( '_' => 0 ) ; if ( $ to == 'byteStr' ) { $ decoded = self :: _decodeToByteStr ( $ encodedStr , $ encodedStrLen , $ mapping , '_' , true ) ; } elseif ( $ to == 'intStr' ) { $ decoded = self :: _crockfordDecodeToIntStr ( $ encodedStr , $ encodedStrLen , $ mapping ) ; } if ( $ hasCheckSymbol ) { if ( $ to == 'byteStr' ) { $ intStr = self :: _byteStrToIntStr ( $ decoded ) ; } elseif ( $ to == 'intStr' ) { $ intStr = $ decoded ; } $ modulus = ( int ) self :: _intStrModulus ( $ intStr , 37 ) ; if ( $ modulus != $ mapping [ $ checkSymbol ] ) { throw new UnexpectedValueException ( 'Check symbol does not match data.' , self :: E_CHECKSYMBOL_DOES_NOT_MATCH_DATA ) ; } } return $ decoded ; } | Decodes a Crockford base32 encoded string . |
19,653 | public static function decodeZookoToByteStr ( $ encodedStr ) { $ pattern = '/[a-km-uw-z13-9]*/' ; self :: _checkEncodedString ( $ encodedStr , $ pattern ) ; $ encodedStrLen = self :: _byteCount ( $ encodedStr ) ; $ mapping = self :: $ _zookoFlippedAlphabet + array ( '_' => 0 ) ; $ byteStr = self :: _decodeToByteStr ( $ encodedStr , $ encodedStrLen , $ mapping , '_' , true ) ; return $ byteStr ; } | Decodes a Zooko encoded string to a byte - string . |
19,654 | private static function _crockfordDecodeToIntStr ( $ encodedStr , $ encodedStrLen , $ mapping ) { if ( ( $ encodedStrLen * 5 / 8 ) <= PHP_INT_SIZE ) { $ int = 0 ; for ( $ i = 0 ; $ i < $ encodedStrLen ; $ i ++ ) { $ int <<= 5 ; $ int |= $ mapping [ $ encodedStr [ $ i ] ] ; } if ( $ int >= 0 ) return $ int ; } if ( extension_loaded ( 'bcmath' ) ) { $ intStr = '0' ; for ( $ i = 0 ; $ i < $ encodedStrLen ; $ i ++ ) { $ intStr = bcmul ( $ intStr , '32' , 0 ) ; $ intStr = bcadd ( $ intStr , ( string ) $ mapping [ $ encodedStr [ $ i ] ] , 0 ) ; } return $ intStr ; } else { throw new RuntimeException ( 'BC Math functions are not available.' , self :: E_NO_BCMATH ) ; } } | Decodes the given base32 encoded string using the given character mapping to an integer . |
19,655 | public function eachPayment ( $ callback ) { if ( ! is_callable ( $ callback ) ) { throw new \ InvalidArgumentException ( "Argument must be callable" ) ; } foreach ( $ this -> payments as $ payment ) { call_user_func_array ( $ callback , array ( $ payment ) ) ; } } | Loop the payments with a custom callback |
19,656 | private function isValidHookHash ( $ privateKey ) { $ confirmationHash = hash ( 'sha256' , $ privateKey . $ this -> hookAction . $ this -> hookDate ) ; return ( $ this -> hookHash === $ confirmationHash ) ; } | Validates the request hash using the client private key |
19,657 | public static function getInstance ( OutputInterface $ output , InputInterface $ input ) { $ questionHelper = new QuestionHelper ( ) ; $ application = new Application ( 'Code Generator Command Line Interface' , 'Alpha' ) ; $ application -> getHelperSet ( ) -> set ( new FormatterHelper ( ) , 'formatter' ) ; $ application -> getHelperSet ( ) -> set ( $ questionHelper , 'question' ) ; $ context = new CliContext ( $ questionHelper , $ output , $ input , CreateCommandFactory :: getInstance ( $ application ) ) ; $ mainBackbone = MainBackboneFactory :: getInstance ( $ context ) ; $ mainBackbone -> run ( ) ; return $ application ; } | Create CLI instance |
19,658 | protected function getMethods ( ) { if ( $ this -> option ( 'plain' ) ) { return [ ] ; } $ methods = [ 'all' , 'find' , 'create' , 'update' , 'delete' ] ; if ( ( $ only = $ this -> option ( 'only' ) ) && $ only != '' ) { $ methods = array_flip ( array_only ( array_flip ( $ methods ) , $ this -> getArray ( $ only ) ) ) ; } if ( ( $ except = $ this -> option ( 'except' ) ) && $ except != '' ) { $ methods = array_flip ( array_except ( array_flip ( $ methods ) , $ this -> getArray ( $ except ) ) ) ; } return $ methods ; } | Get the methods to implement . |
19,659 | protected function getArray ( $ values ) { $ values = explode ( ',' , $ values ) ; array_walk ( $ values , function ( & $ value ) { $ value = trim ( $ value ) ; } ) ; return $ values ; } | Get an array of the given values . |
19,660 | protected function compileFileName ( $ className ) { if ( ! $ className ) { return false ; } $ className = str_replace ( $ this -> getAppNamespace ( ) , '' , $ className ) ; $ className = str_replace ( '\\' , DIRECTORY_SEPARATOR , $ className ) ; return $ className . '.php' ; } | Get a compiled file name for the given full class name . |
19,661 | protected function getContractName ( ) { if ( ! $ this -> input -> getOption ( 'contract' ) ) { return false ; } $ className = $ this -> getClassName ( ) ; return $ this -> getContractNamespace ( ) . '\\' . $ className ; } | Get the contract interface name . |
19,662 | protected function getRepositoryName ( ) { $ prefix = $ this -> getClassNamePrefix ( ) ; $ name = $ this -> getClassName ( ) ; if ( $ this -> input -> getOption ( 'contract' ) ) { $ name = $ prefix . $ name ; } return $ this -> getNamespace ( ) . '\\' . $ name ; } | Get the repository name . |
19,663 | protected function getClassNamePrefix ( ) { $ prefix = $ this -> input -> getOption ( 'prefix' ) ; if ( empty ( $ prefix ) ) { $ prefix = $ this -> classNamePrefix ; } return $ prefix ; } | Get class name prefix . |
19,664 | protected function getClassNameSuffix ( ) { $ suffix = $ this -> input -> getOption ( 'suffix' ) ; if ( empty ( $ suffix ) ) { $ suffix = $ this -> classNameSuffix ; } return $ suffix ; } | Get class name suffix . |
19,665 | protected function getModelReflection ( ) { $ modelClassName = str_replace ( '/' , '\\' , $ this -> input -> getArgument ( 'model' ) ) ; try { $ reflection = new ReflectionClass ( $ this -> getAppNamespace ( ) . $ modelClassName ) ; } catch ( \ ReflectionException $ e ) { $ reflection = new ReflectionClass ( $ modelClassName ) ; } if ( ! $ reflection -> isSubclassOf ( Model :: class ) || ! $ reflection -> isInstantiable ( ) ) { throw new NotAnInstanceOfException ( sprintf ( 'The model must be an instance of [%s]' , Model :: class ) ) ; } return $ reflection ; } | Get the model class name . |
19,666 | protected function getNamespace ( $ namespace = null ) { if ( ! is_null ( $ namespace ) ) { $ parts = explode ( '\\' , $ namespace ) ; array_pop ( $ parts ) ; return join ( '\\' , $ parts ) ; } return $ this -> getAppNamespace ( ) . $ this -> namespace ; } | Get the namespace of the repositories classes . |
19,667 | public function submit ( FormEvent $ event ) { $ user = $ event -> getData ( ) ; if ( null === $ user ) { return ; } if ( $ this -> currentUser !== null && $ this -> currentUser !== $ user && $ event -> getForm ( ) -> has ( 'activated' ) ) { $ activated = $ event -> getForm ( ) -> get ( 'activated' ) -> getData ( ) ; if ( $ activated && $ user -> getRegistrationToken ( ) ) { $ user -> setRegistrationToken ( null ) ; } elseif ( ! $ activated && ! $ user -> getRegistrationToken ( ) ) { $ user -> setRegistrationToken ( hash ( "sha1" , rand ( ) ) ) ; } } } | Checkt form fields by SUBMIT FormEvent |
19,668 | public function preSetData ( FormEvent $ event ) { $ user = $ event -> getData ( ) ; if ( null === $ user ) { return ; } if ( $ this -> currentUser !== null && $ this -> currentUser !== $ user ) { $ event -> getForm ( ) -> add ( $ this -> factory -> createNamed ( 'activated' , 'checkbox' , null , array ( 'data' => $ user -> getRegistrationToken ( ) ? false : true , 'auto_initialize' => false , 'label' => 'Activated' , 'required' => false , 'mapped' => false ) ) ) ; } } | Checkt form fields by PRE_SET_DATA FormEvent |
19,669 | public function server ( $ name = null ) { if ( empty ( $ name ) ) { $ name = $ this -> getDefaultServerName ( ) ; } if ( ! isset ( $ this -> servers [ $ name ] ) ) { $ this -> servers [ $ name ] = $ this -> makeServer ( $ name ) ; } return $ this -> servers [ $ name ] ; } | Get a server instance . |
19,670 | protected function makeServer ( $ name ) { $ config = $ this -> getConfig ( $ name ) ; if ( empty ( $ config ) ) { throw new \ InvalidArgumentException ( "Unable to instantiate Glide server because you provide en empty configuration, \"{$name}\" is probably a wrong server name." ) ; } if ( array_key_exists ( $ config [ 'source' ] , $ this -> app [ 'config' ] [ 'filesystems' ] [ 'disks' ] ) ) { $ config [ 'source' ] = $ this -> app [ 'filesystem' ] -> disk ( $ config [ 'source' ] ) -> getDriver ( ) ; } if ( array_key_exists ( $ config [ 'cache' ] , $ this -> app [ 'config' ] [ 'filesystems' ] [ 'disks' ] ) ) { $ config [ 'cache' ] = $ this -> app [ 'filesystem' ] -> disk ( $ config [ 'cache' ] ) -> getDriver ( ) ; } if ( isset ( $ config [ 'watermarks' ] ) && array_key_exists ( $ config [ 'watermarks' ] , $ this -> app [ 'config' ] [ 'filesystems' ] [ 'disks' ] ) ) { $ config [ 'watermarks' ] = $ this -> app [ 'filesystem' ] -> disk ( $ config [ 'watermarks' ] ) -> getDriver ( ) ; } return new GlideServer ( $ this -> app , $ config ) ; } | Make the server instance . |
19,671 | public function listCommand ( ) { $ this -> console -> writeLn ( 'manaphp commands:' , Console :: FC_GREEN | Console :: AT_BOLD ) ; foreach ( glob ( __DIR__ . '/*Controller.php' ) as $ file ) { $ plainName = basename ( $ file , '.php' ) ; if ( in_array ( $ plainName , [ 'BashCompletionController' , 'HelpController' ] , true ) ) { continue ; } $ this -> console -> writeLn ( ' - ' . $ this -> console -> colorize ( Text :: underscore ( basename ( $ plainName , 'Controller' ) ) , Console :: FC_YELLOW ) ) ; $ commands = $ this -> _getCommands ( __NAMESPACE__ . "\\" . $ plainName ) ; $ width = max ( max ( array_map ( 'strlen' , array_keys ( $ commands ) ) ) , 18 ) ; foreach ( $ commands as $ command => $ description ) { $ this -> console -> writeLn ( ' ' . $ this -> console -> colorize ( $ command , Console :: FC_CYAN , $ width ) . ' ' . $ description ) ; } } if ( $ this -> alias -> has ( '@cli' ) ) { $ this -> console -> writeLn ( 'application commands: ' , Console :: FC_GREEN | Console :: AT_BOLD ) ; foreach ( glob ( $ this -> alias -> resolve ( '@cli/*Controller.php' ) ) as $ file ) { $ plainName = basename ( $ file , '.php' ) ; $ this -> console -> writeLn ( ' - ' . $ this -> console -> colorize ( Text :: underscore ( basename ( $ plainName , 'Controller' ) ) , Console :: FC_YELLOW ) ) ; $ commands = $ this -> _getCommands ( $ this -> alias -> resolveNS ( "@ns.cli\\$plainName" ) ) ; $ width = max ( max ( array_map ( 'strlen' , array_keys ( $ commands ) ) ) , 18 ) ; foreach ( $ commands as $ command => $ description ) { $ this -> console -> writeLn ( ' ' . $ this -> console -> colorize ( $ command , Console :: FC_CYAN , $ width + 1 ) . ' ' . $ description ) ; } } } return 0 ; } | list all commands |
19,672 | public static function getInstance ( ContextInterface $ context ) { return new CreateSourceBackbone ( MetadataSourceQuestionFactory :: getInstance ( $ context ) , MetaDataConfigDAOFactory :: getInstance ( $ context ) , $ context ) ; } | Create CreateSourceBackbone instance |
19,673 | public function listCommand ( ) { $ this -> console -> writeLn ( 'tasks list:' ) ; $ tasks = [ ] ; $ tasksDir = $ this -> alias -> resolve ( '@app/Tasks' ) ; if ( is_dir ( $ tasksDir ) ) { foreach ( glob ( "$tasksDir/*Task.php" ) as $ file ) { $ task = basename ( $ file , 'Task.php' ) ; $ tasks [ ] = [ 'name' => Text :: underscore ( $ task ) , 'desc' => $ this -> _getTaskDescription ( $ task ) ] ; } } $ width = max ( array_map ( static function ( $ v ) { return strlen ( $ v [ 'name' ] ) ; } , $ tasks ) ) + 3 ; foreach ( $ tasks as $ task ) { $ this -> console -> writeLn ( [ ' :1 :2' , $ this -> console -> colorize ( $ task [ 'name' ] , Console :: FC_MAGENTA , $ width ) , $ task [ 'desc' ] ] ) ; } } | list all tasks |
19,674 | public static function isVendorClass ( $ classNameOrObject ) { $ className = ( is_object ( $ classNameOrObject ) ) ? get_class ( $ classNameOrObject ) : $ classNameOrObject ; if ( ! class_exists ( $ className ) ) { $ message = '"' . $ className . '" is not the name of a loadable class.' ; throw new \ InvalidArgumentException ( $ message ) ; } $ reflection = new \ ReflectionClass ( $ className ) ; if ( $ reflection -> isInternal ( ) ) { return false ; } return static :: isVendorFile ( $ reflection -> getFileName ( ) ) ; } | Checks if the given class is located in the vendor directory . |
19,675 | public static function isVendorFile ( $ pathOrFileObject ) { $ path = ( $ pathOrFileObject instanceof \ SplFileInfo ) ? $ pathOrFileObject -> getPathname ( ) : $ pathOrFileObject ; if ( ! file_exists ( $ path ) ) { $ message = '"' . $ path . '" does not reference a file or directory.' ; throw new \ InvalidArgumentException ( $ message ) ; } return strpos ( $ path , static :: getVendorDirectory ( ) ) === 0 ; } | Checks if the given file is located in the vendor directory . |
19,676 | public static function code ( $ constant ) { $ ref = new \ ReflectionClass ( '\PayPay\Structure\PaymentMethodCode' ) ; $ constants = $ ref -> getConstants ( ) ; if ( ! isset ( $ constants [ $ constant ] ) ) { throw new \ InvalidArgumentException ( "Invalid payment method code constant " . $ constant ) ; } return $ ref -> getConstant ( $ constant ) ; } | Helper method to get a code using the class constant name . |
19,677 | protected function _transform ( $ path_src ) { $ path = ( string ) $ path_src ; if ( strpos ( $ path , ',' ) !== false ) { $ paths = explode ( ',' , $ path ) ; $ expressions = [ ] ; foreach ( $ paths as $ path ) { $ xpath = $ this -> transform ( trim ( $ path ) ) ; if ( is_string ( $ xpath ) ) { $ expressions [ ] = $ xpath ; } elseif ( is_array ( $ xpath ) ) { $ expressions = array_merge ( $ expressions , $ xpath ) ; } } return implode ( '|' , $ expressions ) ; } $ paths = [ '//' ] ; $ path = preg_replace ( '|\s+>\s+|' , '>' , $ path ) ; $ segments = preg_split ( '/\s+/' , $ path ) ; foreach ( $ segments as $ key => $ segment ) { $ pathSegment = static :: _tokenize ( $ segment ) ; if ( 0 === $ key ) { if ( 0 === strpos ( $ pathSegment , '[contains(' ) ) { $ paths [ 0 ] .= '*' . ltrim ( $ pathSegment , '*' ) ; } else { $ paths [ 0 ] .= $ pathSegment ; } continue ; } if ( 0 === strpos ( $ pathSegment , '[contains(' ) ) { foreach ( $ paths as $ pathKey => $ xpath ) { $ paths [ $ pathKey ] .= '//*' . ltrim ( $ pathSegment , '*' ) ; $ paths [ ] = $ xpath . $ pathSegment ; } } else { foreach ( $ paths as $ pathKey => $ xpath ) { $ paths [ $ pathKey ] .= '//' . $ pathSegment ; } } } if ( 1 === count ( $ paths ) ) { return $ paths [ 0 ] ; } return implode ( '|' , $ paths ) ; } | Transform CSS expression to XPath |
19,678 | protected static function _tokenize ( $ expression_src ) { $ expression = str_replace ( '>' , '/' , $ expression_src ) ; $ expression = preg_replace ( '|#([a-z][a-z0-9_-]*)|i' , "[@id='$1']" , $ expression ) ; $ expression = preg_replace ( '|(?<![a-z0-9_-])(\[@id=)|i' , '*$1' , $ expression ) ; $ expression = preg_replace_callback ( '|\[@?([a-z0-9_-]*)([~\*\^\$\|\!])?=([^\[]+)\]|i' , static function ( $ matches ) { $ attr = strtolower ( $ matches [ 1 ] ) ; $ type = $ matches [ 2 ] ; $ val = trim ( $ matches [ 3 ] , "'\" \t" ) ; $ field = ( $ attr === '' ? 'text()' : '@' . $ attr ) ; $ items = [ ] ; foreach ( explode ( strpos ( $ val , '|' ) !== false ? '|' : '&' , $ val ) as $ word ) { if ( $ type === '' ) { $ items [ ] = "$field='$word'" ; } elseif ( $ type === '~' ) { $ items [ ] = "contains(concat(' ', normalize-space($field), ' '), ' $word ')" ; } elseif ( $ type === '|' ) { $ item = "$field='$word' or starts-with($field,'$word-')" ; $ items [ ] = $ word === $ val ? $ item : "($item)" ; } elseif ( $ type === '!' ) { $ item = "not($field) or $field!='$word'" ; $ items [ ] = $ word === $ val ? $ item : "($item)" ; } else { $ items [ ] = [ '*' => 'contains' , '^' => 'starts-with' , '$' => 'ends-with' ] [ $ type ] . "($field, '$word')" ; } } return '[' . implode ( strpos ( $ val , '|' ) !== false ? ' or ' : ' and ' , $ items ) . ']' ; } , $ expression ) ; $ expression = preg_replace_callback ( '|\[(!?)([a-z][a-z0-9_-\|&]*)\]|i' , static function ( $ matches ) { $ val = $ matches [ 2 ] ; $ op = strpos ( $ val , '|' ) !== false ? '|' : '&' ; $ items = [ ] ; foreach ( explode ( $ op , $ val ) as $ word ) { $ items [ ] = '@' . $ word ; } $ r = '[' . implode ( $ op === '|' ? ' or ' : ' and ' , $ items ) . ']' ; return $ matches [ 1 ] === '!' ? "not($r)" : $ r ; } , $ expression ) ; if ( false === strpos ( $ expression , '[@' ) ) { $ expression = preg_replace ( '|\.([a-z][a-z0-9_-]*)|i' , "[contains(concat(' ', normalize-space(@class), ' '), ' \$1 ')]" , $ expression ) ; } $ expression = str_replace ( '**' , '*' , $ expression ) ; return $ expression ; } | Tokenize CSS expressions to XPath |
19,679 | protected function sortItems ( & $ items ) { $ this -> safeUaSortItems ( $ items , function ( $ item1 , $ item2 ) { if ( empty ( $ item1 [ 'order' ] ) || empty ( $ item2 [ 'order' ] ) || $ item1 [ 'order' ] == $ item2 [ 'order' ] ) { return 0 ; } return ( $ item1 [ 'order' ] < $ item2 [ 'order' ] ) ? - 1 : 1 ; } ) ; } | Sort items according to the order key value |
19,680 | protected function isGranted ( array $ configuration ) { if ( ! isset ( $ configuration [ 'roles' ] ) ) { return true ; } if ( ! is_array ( $ configuration [ 'roles' ] ) ) { return true ; } foreach ( $ configuration [ 'roles' ] as $ role ) { if ( $ this -> authorizationChecker -> isGranted ( $ role ) ) { return true ; } } return false ; } | Check if security context grant rights on menu item |
19,681 | protected function process ( ) { $ output = "" ; $ offset = 0 ; $ this -> shell -> _initShell ( ) ; while ( true ) { $ temp = $ this -> shell -> _get_channel_packet ( SSH2 :: CHANNEL_EXEC ) ; switch ( true ) { case $ temp === true : case $ temp === false : return $ output ; default : $ output .= $ temp ; if ( $ this -> handle_data ( substr ( $ output , $ offset ) ) ) { $ offset = strlen ( $ output ) ; } } } } | Process remote command execution |
19,682 | public function generateCommand ( $ length = 32 , $ lowercase = 0 ) { $ key = $ this -> random -> getBase ( $ length ) ; $ this -> console -> writeLn ( $ lowercase ? strtolower ( $ key ) : $ key ) ; } | generate random key |
19,683 | public final function addColumn ( Column \ ColumnAbstract $ column ) { return $ this -> _columns [ $ column -> getName ( ) ] = $ column -> setGrid ( $ this ) ; } | Dodaje Column grida |
19,684 | public function countUnread ( User $ user ) { return $ this -> createQueryBuilder ( 'm' ) -> select ( 'count(m)' ) -> join ( 'm.userMessages' , 'um' ) -> where ( 'm.user != :sender' ) -> orWhere ( 'm.user IS NULL' ) -> andWhere ( 'um.user = :user' ) -> andWhere ( 'um.isRead = 0' ) -> andWhere ( 'um.isRemoved = 0' ) -> setParameter ( ':user' , $ user ) -> setParameter ( ':sender' , $ user ) -> getQuery ( ) -> getSingleScalarResult ( ) ; } | Counts the number of unread messages of a user . |
19,685 | public static function imagesByObject ( $ object = null , $ objectId = null ) { return self :: byObject ( $ object , $ objectId ) -> whereClass ( ) -> equals ( 'image' ) ; } | Zapytanie o obrazy po obiektach i id |
19,686 | public static function stickyByObject ( $ object = null , $ objectId = null , $ class = null ) { $ q = self :: byObject ( $ object , $ objectId ) -> whereSticky ( ) -> equals ( 1 ) ; if ( null !== $ class ) { $ q -> andFieldClass ( ) -> equals ( $ class ) ; } return $ q ; } | Przyklejone po obiekcie i id |
19,687 | public static function notImagesByObject ( $ object = null , $ objectId = null ) { return self :: byObject ( $ object , $ objectId ) -> whereClass ( ) -> notEquals ( 'image' ) ; } | Nie obrazy po obiekcie i id |
19,688 | public function option ( $ option = null ) { if ( ! is_null ( $ option ) ) { $ this -> option = $ option ; $ this -> buildDrivers ( ) ; } return $ this ; } | Set the hasher option . |
19,689 | private function buildDrivers ( ) { $ drivers = $ this -> getHasherConfig ( 'drivers' , [ ] ) ; foreach ( $ drivers as $ name => $ driver ) { $ this -> buildDriver ( $ name , $ driver ) ; } } | Build all hash drivers . |
19,690 | private function buildDriver ( $ name , array $ driver ) { return $ this -> drivers [ $ name ] = new $ driver [ 'driver' ] ( Arr :: get ( $ driver , 'options.' . $ this -> getDefaultOption ( ) , [ ] ) ) ; } | Build the driver . |
19,691 | public function minifyCommand ( ) { $ ManaPHPSrcDir = $ this -> alias -> get ( '@manaphp' ) ; $ ManaPHPDstDir = $ ManaPHPSrcDir . '_' . date ( 'ymd' ) ; $ totalClassLines = 0 ; $ totalInterfaceLines = 0 ; $ totalLines = 0 ; $ fileLines = [ ] ; $ sourceFiles = $ this -> _getSourceFiles ( $ ManaPHPSrcDir ) ; foreach ( $ sourceFiles as $ file ) { $ dstFile = str_replace ( $ ManaPHPSrcDir , $ ManaPHPDstDir , $ file ) ; $ content = $ this -> _minify ( $ this -> filesystem -> fileGet ( $ file ) ) ; $ lineCount = substr_count ( $ content , strpos ( $ content , "\r" ) !== false ? "\r" : "\n" ) ; if ( strpos ( $ file , 'Interface.php' ) ) { $ totalInterfaceLines += $ lineCount ; $ totalLines += $ lineCount ; } else { $ totalClassLines += $ lineCount ; $ totalLines += $ lineCount ; } $ this -> console -> writeLn ( $ content ) ; $ this -> filesystem -> filePut ( $ dstFile , $ content ) ; $ fileLines [ $ file ] = $ lineCount ; } asort ( $ fileLines ) ; $ i = 1 ; $ this -> console -> writeLn ( '------------------------------------------------------' ) ; foreach ( $ fileLines as $ file => $ line ) { $ this -> console -> writeLn ( sprintf ( '%3d %3d %.3f' , $ i ++ , $ line , $ line / $ totalLines * 100 ) . ' ' . substr ( $ file , strpos ( $ file , 'ManaPHP' ) ) ) ; } $ this -> console -> writeLn ( '------------------------------------------------------' ) ; $ this -> console -> writeLn ( 'total lines: ' . $ totalLines ) ; $ this -> console -> writeLn ( 'class lines: ' . $ totalClassLines ) ; $ this -> console -> writeLn ( 'interface lines: ' . $ totalInterfaceLines ) ; return 0 ; } | minify framework source code |
19,692 | public function genJsonCommand ( $ source ) { $ classNames = [ ] ; foreach ( require $ source as $ className ) { if ( preg_match ( '#^ManaPHP\\\\.*$#' , $ className ) ) { $ classNames [ ] = $ className ; } } $ output = __DIR__ . '/manaphp_lite.json' ; if ( $ this -> filesystem -> fileExists ( $ output ) ) { $ data = json_encode ( $ this -> filesystem -> fileGet ( $ output ) ) ; } else { $ data = [ 'output' => '@root/manaphp.lite' ] ; } $ data [ 'classes' ] = $ classNames ; $ this -> filesystem -> filePut ( $ output , json_encode ( $ data , JSON_PRETTY_PRINT ) ) ; $ this -> console -> writeLn ( json_encode ( $ classNames , JSON_PRETTY_PRINT ) ) ; } | generate manaphp_lite . json file |
19,693 | public function getIterator ( ) { $ tagsById = $ this -> container -> findTaggedServiceIds ( $ this -> tag ) ; $ taggedServices = array ( ) ; foreach ( $ tagsById as $ id => $ tagDefinitions ) { foreach ( $ tagDefinitions as $ tagDefinition ) { $ taggedServices [ ] = new TaggedService ( $ id , $ tagDefinition ) ; } } return new \ ArrayIterator ( $ taggedServices ) ; } | Returns the iterator . |
19,694 | public function addCustomButton ( $ iconName , array $ params = [ ] , $ hashTarget = '' ) { $ customButtons = is_array ( $ this -> getOption ( 'customButtons' ) ) ? $ this -> getOption ( 'customButtons' ) : [ ] ; $ customButtons [ ] = [ 'iconName' => $ iconName , 'params' => $ params , 'hashTarget' => $ hashTarget ] ; return $ this -> setOption ( 'customButtons' , $ customButtons ) ; } | Dodaje dowolny button |
19,695 | public function getName ( $ ucfirst = false ) { $ value = $ this -> camelCase ( $ this -> name ) ; if ( true === $ ucfirst ) { return ucfirst ( $ value ) ; } else { return $ value ; } } | Get Column name |
19,696 | public function getFiles ( $ onlySuccessful = true ) { $ context = $ this -> _context ; $ files = [ ] ; foreach ( $ context -> _FILES as $ key => $ file ) { if ( is_int ( $ file [ 'error' ] ) ) { if ( ! $ onlySuccessful || $ file [ 'error' ] === UPLOAD_ERR_OK ) { $ fileInfo = [ 'name' => $ file [ 'name' ] , 'type' => $ file [ 'type' ] , 'tmp_name' => $ file [ 'tmp_name' ] , 'error' => $ file [ 'error' ] , 'size' => $ file [ 'size' ] , ] ; $ files [ ] = new File ( $ key , $ fileInfo ) ; } } else { $ countFiles = count ( $ file [ 'error' ] ) ; for ( $ i = 0 ; $ i < $ countFiles ; $ i ++ ) { if ( ! $ onlySuccessful || $ file [ 'error' ] [ $ i ] === UPLOAD_ERR_OK ) { $ fileInfo = [ 'name' => $ file [ 'name' ] [ $ i ] , 'type' => $ file [ 'type' ] [ $ i ] , 'tmp_name' => $ file [ 'tmp_name' ] [ $ i ] , 'error' => $ file [ 'error' ] [ $ i ] , 'size' => $ file [ 'size' ] [ $ i ] , ] ; $ files [ ] = new File ( $ key , $ fileInfo ) ; } } } } return $ files ; } | Gets attached files as \ ManaPHP \ Http \ Request \ File instances |
19,697 | public function beforeSave ( ) { $ this -> getRecord ( ) -> active = 0 ; $ this -> getRecord ( ) -> cmsAuthIdReply = \ App \ Registry :: $ auth -> getId ( ) ; return true ; } | Ustawienie opcji przed zapisem |
19,698 | public function destroy ( $ session_id = null ) { if ( $ session_id ) { $ this -> eventsManager -> fireEvent ( 'session:destroy' , $ this , [ 'session_id' => $ session_id ] ) ; $ this -> do_destroy ( $ session_id ) ; } else { $ context = $ this -> _context ; if ( ! $ context -> started ) { $ this -> _start ( ) ; } $ this -> eventsManager -> fireEvent ( 'session:destroy' , $ this , [ 'session_id' => $ session_id , 'context' => $ context ] ) ; $ context -> started = false ; $ context -> is_dirty = false ; $ context -> session_id = null ; $ context -> _SESSION = null ; $ this -> do_destroy ( $ context -> session_id ) ; $ params = $ this -> _cookie_params ; $ this -> cookies -> delete ( $ this -> _name , $ params [ 'path' ] , $ params [ 'domain' ] , $ params [ 'secure' ] , $ params [ 'httponly' ] ) ; } } | Destroys the active session or assigned session |
19,699 | public function get ( $ name = null , $ default = null ) { $ context = $ this -> _context ; if ( ! $ context -> started ) { $ this -> _start ( ) ; } if ( $ name === null ) { return $ context -> _SESSION ; } elseif ( isset ( $ context -> _SESSION [ $ name ] ) ) { return $ context -> _SESSION [ $ name ] ; } else { return $ default ; } } | Gets a session variable from an application context |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.