idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
42,700 | private function copySource ( TranslationValueInterface $ source , WritableTranslationValueInterface $ target ) : void { if ( self :: DO_NOT_COPY === $ this -> copySource ) { return ; } if ( ( $ oldValue = $ target -> getSource ( ) ) === ( $ newValue = $ source -> getSource ( ) ) ) { $ this -> logger -> log ( $ this -> logLevel , '{key}: Source is same, no need to update.' , [ 'key' => $ target -> getKey ( ) , 'old' => $ oldValue , 'new' => $ newValue ] ) ; return ; } if ( ( self :: COPY_IF_EMPTY === $ this -> copySource ) && ! $ target -> isSourceEmpty ( ) ) { $ this -> logger -> log ( $ this -> logLevel , '{key}: Source is not empty, no need to update.' , [ 'key' => $ target -> getKey ( ) , 'old' => $ oldValue , 'new' => $ newValue ] ) ; return ; } $ this -> logger -> log ( LogLevel :: NOTICE , '{key}: Updating source value.' , [ 'key' => $ target -> getKey ( ) , 'old' => $ oldValue , 'new' => $ newValue ] ) ; if ( $ this -> dryRun ) { return ; } $ target -> setSource ( $ newValue ) ; } | Copy the source value . |
42,701 | private function copyTarget ( TranslationValueInterface $ source , WritableTranslationValueInterface $ target ) : void { if ( self :: DO_NOT_COPY === $ this -> copyTarget ) { return ; } if ( ( ( $ oldValue = $ target -> getTarget ( ) ) === ( $ newValue = $ source -> getTarget ( ) ) ) || ( $ target -> isTargetEmpty ( ) && $ source -> isTargetEmpty ( ) ) ) { $ this -> logger -> log ( $ this -> logLevel , '{key}: Target is same, no need to update.' , [ 'key' => $ target -> getKey ( ) , 'old' => $ oldValue , 'new' => $ newValue ] ) ; return ; } if ( ( self :: COPY_IF_EMPTY === $ this -> copyTarget ) && ! $ target -> isTargetEmpty ( ) ) { $ this -> logger -> log ( $ this -> logLevel , '{key}: Target is not empty, no need to update.' , [ 'key' => $ target -> getKey ( ) , 'old' => $ oldValue , 'new' => $ newValue ] ) ; return ; } $ this -> logger -> log ( LogLevel :: NOTICE , '{key}: Updating target value.' , [ 'key' => $ target -> getKey ( ) , 'old' => $ oldValue , 'new' => $ newValue ] ) ; if ( $ this -> dryRun ) { return ; } if ( null === $ value = $ source -> getTarget ( ) ) { $ target -> clearTarget ( ) ; return ; } $ target -> setTarget ( $ value ) ; } | Copy the target value . |
42,702 | private function cleanTarget ( ) : void { foreach ( $ this -> targetDictionary -> keys ( ) as $ key ) { if ( ! $ this -> sourceDictionary -> has ( $ key ) || $ this -> sourceDictionary -> get ( $ key ) -> isSourceEmpty ( ) ) { $ this -> logger -> log ( $ this -> logLevel , 'Removing obsolete {key}.' , [ 'key' => $ key ] ) ; if ( $ this -> dryRun ) { continue ; } $ this -> targetDictionary -> remove ( $ key ) ; } } } | Clean the target language . |
42,703 | private function isFiltered ( $ key ) : bool { foreach ( $ this -> filters as $ expression ) { if ( preg_match ( $ expression , $ key ) ) { $ this -> logger -> debug ( sprintf ( '"%1$s" is filtered by "%2$s' , $ key , $ expression ) ) ; return true ; } } return false ; } | Check if the passed key is filtered by any of the regexes . |
42,704 | public function getContentReplies ( string $ author , string $ permalink ) { $ request = [ 'route' => 'get_content_replies' , 'query' => [ 'author' => $ author , 'permlink' => $ permalink , ] ] ; return parent :: call ( $ request ) ; } | Get content replies |
42,705 | public function getContentAllReplies ( string $ author , string $ permalink ) { $ request = $ this -> getContentReplies ( $ author , $ permalink ) ; if ( is_array ( $ request ) ) { foreach ( $ request as $ key => $ item ) { if ( $ item [ 'children' ] > 0 ) $ request [ $ key ] [ 'replies' ] = $ this -> getContentAllReplies ( $ item [ 'author' ] , $ item [ 'permlink' ] ) ; else $ request [ $ key ] [ 'replies' ] = [ ] ; } } return $ request ; } | Get all content replies |
42,706 | public static function run ( HelperSet $ helperSet , $ commands = array ( ) ) { $ cli = new Application ( 'PoolDBM Command Line Interface' , Version :: VERSION ) ; $ cli -> setCatchExceptions ( true ) ; $ cli -> setHelperSet ( new HelperSet ( $ helperSet ) ) ; self :: addDefaultCommands ( $ cli ) ; $ cli -> addCommands ( $ commands ) ; $ cli -> run ( ) ; } | Runs console with the given helperset . |
42,707 | private function block ( $ textblock ) { $ length = 0 ; foreach ( $ textblock as $ line ) { $ n = strlen ( $ line ) ; if ( $ length < $ n ) { $ length = $ n ; } } foreach ( $ textblock as $ i => $ line ) { $ textblock [ $ i ] .= str_repeat ( ' ' , $ length - strlen ( $ line ) ) ; } return $ textblock ; } | Fill each line with spaces so that all are equal in length . |
42,708 | public static function get ( $ symbol ) { $ symbol = strtolower ( $ symbol ) ; if ( isset ( static :: $ dictionary [ $ symbol ] ) ) return static :: $ dictionary [ $ symbol ] ; else return false ; } | Get symbol by name |
42,709 | public function newAction ( ) { $ entity = new ProductOrder ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; } | Displays a form to create a new ProductOrder entity . |
42,710 | public function errors ( ) : array { $ errors = [ ] ; foreach ( $ this -> tests as $ error => $ test ) { if ( ! $ test ( $ this -> getValue ( ) ) ) { $ errors [ ] = $ error ; } } return $ errors ; } | Get array of errors for element . |
42,711 | public function validateWithRules ( array $ validateRules , array $ validateMessages = [ ] , array $ parametricConverter = [ ] ) { $ this -> validateDataWithRules ( $ this -> getParameters ( ) , $ validateRules , $ validateMessages , $ parametricConverter ) ; } | Validate all parameters of request with defined rules . |
42,712 | public function validateDataWithRules ( array $ data , array $ validateRules , array $ validateMessages = [ ] , array $ parametricConverter = [ ] ) { foreach ( $ validateRules as $ key => $ rules ) { $ value = array_key_exists ( $ key , $ data ) ? $ data [ $ key ] : null ; if ( array_key_exists ( 'nullable' , $ rules ) && $ rules [ 'nullable' ] && is_null ( $ value ) ) { continue ; } unset ( $ rules [ 'nullable' ] ) ; $ defaultParametricConverter = ( method_exists ( $ this , 'getParametricConverter' ) && is_array ( $ this -> getParametricConverter ( ) ) ) ? $ this -> getParametricConverter ( ) : [ ] ; $ parametricConverter = array_merge ( $ defaultParametricConverter , $ parametricConverter ) ; $ parameter = ( array_key_exists ( $ key , $ parametricConverter ) ) ? $ parametricConverter [ $ key ] : $ key ; foreach ( $ rules as $ ruleName => $ ruleParameter ) { if ( $ ruleName === 'callback' ) { if ( ! is_callable ( $ ruleParameter ) ) { throw new BadMethodCallException ( 'The reference of rule named `callback` must be a valid callable. You provided ' . $ this -> getValueDescription ( $ ruleParameter ) . '.' ) ; } call_user_func ( $ ruleParameter , $ value , InvalidRequestException :: class ) ; } else { $ method = 'check' . ucfirst ( Helper :: camelCase ( $ ruleName ) ) ; if ( ! method_exists ( $ this , $ method ) ) { throw new BadMethodCallException ( 'Call to undefined the ' . get_class ( $ this ) . '::' . $ method . '() validator that associated with the `' . $ ruleName . '` rule' ) ; } if ( ! $ this -> $ method ( $ value , $ ruleParameter ) ) { $ message = isset ( $ validateMessages [ $ key ] [ $ ruleName ] ) ? $ validateMessages [ $ key ] [ $ ruleName ] : null ; throw new InvalidRequestException ( $ this -> formatMessage ( $ parameter , $ ruleName , $ ruleParameter , $ message ) ) ; } } } } } | Validate data with defined rules |
42,713 | protected function formatMessage ( $ parameter , $ ruleName , $ ruleParameter , $ message = null ) { $ message = $ message ? : ( isset ( $ this -> validateMessages [ $ ruleName ] ) ? $ this -> validateMessages [ $ ruleName ] : $ this -> validateMessages [ 'default' ] ) ; $ message = str_replace ( ':parameter' , $ parameter , $ message ) ; $ method = 'format' . ucfirst ( Helper :: camelCase ( $ ruleName ) ) . 'Message' ; if ( method_exists ( $ this , $ method ) ) { return $ this -> $ method ( $ ruleParameter , $ message ) ; } return $ message ; } | Format message for special rule |
42,714 | protected function getValueDescription ( $ value ) { switch ( true ) { case ( is_numeric ( $ value ) ) : $ value = strval ( $ value ) ; break ; case ( is_bool ( $ value ) && $ value ) : $ value = '(boolean) true' ; break ; case ( is_bool ( $ value ) && ! $ value ) : $ value = '(boolean) false' ; break ; case ( is_null ( $ value ) ) : $ value = 'null value' ; break ; default : break ; } return $ value ; } | Get description of value |
42,715 | protected function _containerHasPath ( $ container , $ path ) { $ originalPath = $ path ; $ path = $ this -> _normalizeArray ( $ path ) ; $ pathLength = count ( $ path ) ; if ( ! $ pathLength ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Not a valid path' ) , null , null , $ originalPath ) ; } $ lastSegment = $ path [ $ pathLength - 1 ] ; $ service = $ container ; foreach ( $ path as $ segment ) { $ hasSegment = $ this -> _containerHas ( $ service , $ segment ) ; if ( ! $ hasSegment ) { return false ; } elseif ( $ segment !== $ lastSegment ) { $ service = $ this -> _containerGet ( $ service , $ segment ) ; } } return true ; } | Check that path exists on a chain of nested containers . |
42,716 | public function guessType ( $ class , $ property ) { $ reflClass = new \ ReflectionClass ( $ class ) ; if ( $ reflClass -> hasProperty ( $ property ) ) { $ reflProp = $ reflClass -> getProperty ( $ property ) ; if ( $ reflProp -> isPublic ( ) ) { return null ; } } if ( ! $ reflClass -> hasMethod ( 'get' . ucfirst ( $ property ) ) && ( $ reflClass -> hasMethod ( 'is' . ucfirst ( $ property ) ) || $ reflClass -> hasMethod ( 'has' . ucfirst ( $ property ) ) ) ) { return new TypeGuess ( 'boolean' , array ( ) , Guess :: HIGH_CONFIDENCE ) ; } } | If a property has an isser or a hasser and not getter it is assumed to be a boolean type |
42,717 | protected function isExceptionRecoverable ( $ e ) { if ( $ e instanceof \ ErrorException ) { $ ignore = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_STRICT ; return ( ( $ ignore & $ e -> getSeverity ( ) ) != 0 ) ; } return false ; } | Determines whether an exception is recoverable |
42,718 | protected function createResourcesFromJsonData ( array $ data , ResponseInterface $ response , ApiResourceInterface $ owner ) { $ items = [ ] ; $ className = $ this -> resourceClass ( ) ; foreach ( $ data as $ item ) { $ items [ ] = new $ className ( $ owner -> getApi ( ) , $ item , $ owner ) ; } return $ items ; } | Create resources list from given JSON response . |
42,719 | public function datetime ( $ value ) : bool { if ( ! is_scalar ( $ value ) ) { return false ; } if ( is_numeric ( $ value ) ) { return true ; } return ( int ) strtotime ( $ value ) != 0 ; } | Value has to be valid datetime definition including numeric timestamp . |
42,720 | private function appendChangeSet ( Model $ model , array $ obj , Closure $ handler ) { $ metadata = $ model -> getMetadata ( ) ; $ changeset = $ model -> getChangeSet ( ) ; $ formatter = $ this -> getFormatter ( ) ; foreach ( $ this -> changeSetMethods as $ setKey => $ methods ) { list ( $ metaMethod , $ formatMethod ) = $ methods ; foreach ( $ changeset [ $ setKey ] as $ key => $ values ) { $ value = $ formatter -> $ formatMethod ( $ metadata -> $ metaMethod ( $ key ) , $ values [ 'new' ] ) ; $ obj = $ handler ( $ key , $ value , $ obj ) ; } } return $ obj ; } | Appends the change set values to a database object based on the provided handler . |
42,721 | private function createInsertObj ( Model $ model ) { $ metadata = $ model -> getMetadata ( ) ; $ insert = [ $ this -> getIdentifierKey ( ) => $ this -> convertId ( $ model -> getId ( ) ) , ] ; if ( true === $ metadata -> isChildEntity ( ) ) { $ insert [ $ this -> getPolymorphicKey ( ) ] = $ metadata -> type ; } return $ this -> appendChangeSet ( $ model , $ insert , $ this -> getCreateChangeSetHandler ( ) ) ; } | Creates the database insert object for a Model . |
42,722 | private function getCreateChangeSetHandler ( ) { return function ( $ key , $ value , $ obj ) { if ( null !== $ value ) { $ obj [ $ key ] = $ value ; } return $ obj ; } ; } | Gets the change set handler Closure for create . |
42,723 | private function getUpdateChangeSetHandler ( ) { return function ( $ key , $ value , $ obj ) { $ op = '$set' ; if ( null === $ value ) { $ op = '$unset' ; $ value = 1 ; } $ obj [ $ op ] [ $ key ] = $ value ; return $ obj ; } ; } | Gets the change set handler Closure for update . |
42,724 | public function check ( $ requester , $ request , $ perms ) { $ permission = $ this -> _classes [ 'permission' ] ; return $ permission :: check ( $ requester , $ request , $ perms ) ; } | Check permission access |
42,725 | public static function parse ( array $ argv , array $ format ) { $ result = new Result ( ) ; if ( empty ( $ argv ) ) { $ result -> error = 'empty argv' ; return $ result ; } $ result -> command = array_shift ( $ argv ) ; $ pArgs = false ; $ wait = null ; foreach ( $ argv as $ arg ) { if ( $ wait ) { $ result -> options [ $ wait ] = $ arg ; $ wait = null ; continue ; } if ( substr ( $ arg , 0 , 1 ) === '-' ) { if ( $ pArgs ) { $ result -> error = 'option ' . $ arg . ' after argument' ; return $ result ; } $ len = strlen ( $ arg ) ; if ( $ len < 2 ) { return null ; } for ( $ i = 1 ; $ i < $ len ; $ i ++ ) { $ o = substr ( $ arg , $ i , 1 ) ; if ( ! isset ( $ format [ $ o ] ) ) { $ result -> error = 'illegal option -- ' . $ o ; return $ result ; } if ( $ format [ $ o ] ) { if ( $ i < $ len - 1 ) { $ result -> options [ $ o ] = substr ( $ arg , $ i + 1 ) ; } else { $ wait = $ o ; } break ; } else { $ result -> options [ $ o ] = true ; } } } else { $ pArgs = true ; $ result -> args [ ] = $ arg ; } } if ( $ wait !== null ) { $ result -> error = 'option requires an argument -- ' . $ wait ; return $ result ; } return $ result ; } | Parses a command line arguments |
42,726 | public function set_contents ( $ contents , $ handler = NULL ) { $ this -> contents = $ contents ; $ this -> set_content_handler ( $ handler ) ; $ this -> contents = $ this -> handle_writing ( $ contents ) ; return $ this ; } | Set the contents with optional handler instead of the default |
42,727 | protected function set_content_handler ( $ handler ) { $ this -> handler_object = null ; $ this -> content_handler = ( string ) $ handler ; return $ this ; } | Decides a content handler that makes it possible to write non - strings to a file |
42,728 | public function get_content_handler ( $ handler = null ) { if ( ! empty ( $ this -> handler_object ) ) { return $ this -> handler_object ; } if ( empty ( $ this -> content_handler ) && empty ( $ handler ) ) { if ( ! empty ( $ handler ) ) { $ this -> content_handler = $ handler ; } if ( is_string ( $ this -> contents ) ) { $ this -> content_handler = \ Config :: get ( 'cache.string_handler' , 'string' ) ; } else { $ type = is_object ( $ this -> contents ) ? get_class ( $ this -> contents ) : gettype ( $ this -> contents ) ; $ this -> content_handler = \ Config :: get ( 'cache.' . $ type . '_handler' , 'serialized' ) ; } } $ class = '\\Cache_Handler_' . ucfirst ( $ this -> content_handler ) ; $ this -> handler_object = new $ class ( ) ; return $ this -> handler_object ; } | Gets a specific content handler |
42,729 | private function _rindex ( $ index , array $ values ) : int { if ( is_int ( $ index ) && $ index < 0 ) { return count ( $ values ) + $ index ; } return $ index ; } | Get reverse index |
42,730 | private function _get ( $ index , $ accept_reverse_index ) { $ values = $ this -> getValues ( ) ; if ( $ accept_reverse_index ) { $ index = $ this -> _rindex ( $ index , $ values ) ; } return $ values [ $ index ] ?? null ; } | Get element value |
42,731 | private function _first ( callable $ callback = null ) { $ values = $ this -> getValues ( ) ; if ( $ callback ) { foreach ( $ values as $ key => $ value ) { if ( $ callback ( $ value , $ key ) ) { return $ value ; } } } else { return empty ( $ values ) ? null : $ values [ 0 ] ; } return null ; } | Get head element of the array |
42,732 | private function _last ( callable $ callback = null ) { $ values = $ this -> getValues ( ) ; if ( $ callback ) { foreach ( array_reverse ( $ values ) as $ key => $ value ) { if ( $ callback ( $ value , $ key ) ) { return $ value ; } } } else { return empty ( $ values ) ? null : $ values [ count ( $ values ) - 1 ] ; } return null ; } | Get tail element of the array |
42,733 | private function _pop ( & $ item ) : array { $ values = $ this -> getValues ( ) ; if ( empty ( $ values ) ) { $ item = null ; return $ values ; } $ item = array_pop ( $ values ) ; return $ values ; } | get item from tail |
42,734 | private function _indexOf ( $ target , int $ start = NULL ) { $ values = $ this -> getValues ( ) ; if ( $ start === NULL ) { $ start = 0 ; } $ size = count ( $ values ) ; for ( $ i = $ start ; $ i < $ size ; $ i ++ ) { $ item = $ values [ $ i ] ; if ( $ item instanceof EqualableInterface ) { if ( $ item -> equals ( $ target ) ) { return $ i ; } } else if ( $ item === $ target ) { return $ i ; } } return FALSE ; } | Find index of element |
42,735 | public function addObjects ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Sport not found.' ] ) ; } try { $ this -> doAddObjects ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors ( ) ] ) ; } $ this -> dispatch ( SportEvent :: PRE_OBJECTS_ADD , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: PRE_SAVE , $ model , $ data ) ; $ rows = $ model -> save ( ) ; $ this -> dispatch ( SportEvent :: POST_OBJECTS_ADD , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: POST_SAVE , $ model , $ data ) ; if ( $ rows > 0 ) { return Updated ( [ 'model' => $ model ] ) ; } return NotUpdated ( [ 'model' => $ model ] ) ; } | Adds Objects to Sport |
42,736 | public function addPositions ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Sport not found.' ] ) ; } try { $ this -> doAddPositions ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors ( ) ] ) ; } $ this -> dispatch ( SportEvent :: PRE_POSITIONS_ADD , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: PRE_SAVE , $ model , $ data ) ; $ rows = $ model -> save ( ) ; $ this -> dispatch ( SportEvent :: POST_POSITIONS_ADD , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: POST_SAVE , $ model , $ data ) ; if ( $ rows > 0 ) { return Updated ( [ 'model' => $ model ] ) ; } return NotUpdated ( [ 'model' => $ model ] ) ; } | Adds Positions to Sport |
42,737 | public function removeObjects ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Sport not found.' ] ) ; } try { $ this -> doRemoveObjects ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors ( ) ] ) ; } $ this -> dispatch ( SportEvent :: PRE_OBJECTS_REMOVE , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: PRE_SAVE , $ model , $ data ) ; $ rows = $ model -> save ( ) ; $ this -> dispatch ( SportEvent :: POST_OBJECTS_REMOVE , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: POST_SAVE , $ model , $ data ) ; if ( $ rows > 0 ) { return Updated ( [ 'model' => $ model ] ) ; } return NotUpdated ( [ 'model' => $ model ] ) ; } | Removes Objects from Sport |
42,738 | public function removePositions ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Sport not found.' ] ) ; } try { $ this -> doRemovePositions ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors ( ) ] ) ; } $ this -> dispatch ( SportEvent :: PRE_POSITIONS_REMOVE , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: PRE_SAVE , $ model , $ data ) ; $ rows = $ model -> save ( ) ; $ this -> dispatch ( SportEvent :: POST_POSITIONS_REMOVE , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: POST_SAVE , $ model , $ data ) ; if ( $ rows > 0 ) { return Updated ( [ 'model' => $ model ] ) ; } return NotUpdated ( [ 'model' => $ model ] ) ; } | Removes Positions from Sport |
42,739 | public function updateGroups ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Sport not found.' ] ) ; } try { $ this -> doUpdateGroups ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors ( ) ] ) ; } $ this -> dispatch ( SportEvent :: PRE_GROUPS_UPDATE , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: PRE_SAVE , $ model , $ data ) ; $ rows = $ model -> save ( ) ; $ this -> dispatch ( SportEvent :: POST_GROUPS_UPDATE , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: POST_SAVE , $ model , $ data ) ; if ( $ rows > 0 ) { return Updated ( [ 'model' => $ model ] ) ; } return NotUpdated ( [ 'model' => $ model ] ) ; } | Updates Groups on Sport |
42,740 | public function updateObjects ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Sport not found.' ] ) ; } try { $ this -> doUpdateObjects ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors ( ) ] ) ; } $ this -> dispatch ( SportEvent :: PRE_OBJECTS_UPDATE , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: PRE_SAVE , $ model , $ data ) ; $ rows = $ model -> save ( ) ; $ this -> dispatch ( SportEvent :: POST_OBJECTS_UPDATE , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: POST_SAVE , $ model , $ data ) ; if ( $ rows > 0 ) { return Updated ( [ 'model' => $ model ] ) ; } return NotUpdated ( [ 'model' => $ model ] ) ; } | Updates Objects on Sport |
42,741 | public function updatePositions ( $ id , $ data ) { $ model = $ this -> get ( $ id ) ; if ( $ model === null ) { return new NotFound ( [ 'message' => 'Sport not found.' ] ) ; } try { $ this -> doUpdatePositions ( $ model , $ data ) ; } catch ( ErrorsException $ e ) { return new NotValid ( [ 'errors' => $ e -> getErrors ( ) ] ) ; } $ this -> dispatch ( SportEvent :: PRE_POSITIONS_UPDATE , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: PRE_SAVE , $ model , $ data ) ; $ rows = $ model -> save ( ) ; $ this -> dispatch ( SportEvent :: POST_POSITIONS_UPDATE , $ model , $ data ) ; $ this -> dispatch ( SportEvent :: POST_SAVE , $ model , $ data ) ; if ( $ rows > 0 ) { return Updated ( [ 'model' => $ model ] ) ; } return NotUpdated ( [ 'model' => $ model ] ) ; } | Updates Positions on Sport |
42,742 | protected function doAddObjects ( Sport $ model , $ data ) { $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Object' ; } else { $ related = ObjectQuery :: create ( ) -> findOneById ( $ entry [ 'id' ] ) ; $ model -> addObject ( $ related ) ; } } if ( count ( $ errors ) > 0 ) { return new ErrorsException ( $ errors ) ; } } | Interal mechanism to add Objects to Sport |
42,743 | protected function doAddPositions ( Sport $ model , $ data ) { $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Position' ; } else { $ related = PositionQuery :: create ( ) -> findOneById ( $ entry [ 'id' ] ) ; $ model -> addPosition ( $ related ) ; } } if ( count ( $ errors ) > 0 ) { return new ErrorsException ( $ errors ) ; } } | Interal mechanism to add Positions to Sport |
42,744 | protected function doAddSkills ( Sport $ model , $ data ) { $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Skill' ; } else { $ related = SkillQuery :: create ( ) -> findOneById ( $ entry [ 'id' ] ) ; $ model -> addSkill ( $ related ) ; } } if ( count ( $ errors ) > 0 ) { return new ErrorsException ( $ errors ) ; } } | Interal mechanism to add Skills to Sport |
42,745 | protected function doRemoveObjects ( Sport $ model , $ data ) { $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Object' ; } else { $ related = ObjectQuery :: create ( ) -> findOneById ( $ entry [ 'id' ] ) ; $ model -> removeObject ( $ related ) ; } } if ( count ( $ errors ) > 0 ) { return new ErrorsException ( $ errors ) ; } } | Interal mechanism to remove Objects from Sport |
42,746 | protected function doRemovePositions ( Sport $ model , $ data ) { $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Position' ; } else { $ related = PositionQuery :: create ( ) -> findOneById ( $ entry [ 'id' ] ) ; $ model -> removePosition ( $ related ) ; } } if ( count ( $ errors ) > 0 ) { return new ErrorsException ( $ errors ) ; } } | Interal mechanism to remove Positions from Sport |
42,747 | protected function doUpdateGroups ( Sport $ model , $ data ) { GroupQuery :: create ( ) -> filterBySport ( $ model ) -> delete ( ) ; $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Group' ; } else { $ related = GroupQuery :: create ( ) -> findOneById ( $ entry [ 'id' ] ) ; $ model -> addGroup ( $ related ) ; } } if ( count ( $ errors ) > 0 ) { throw new ErrorsException ( $ errors ) ; } } | Internal update mechanism of Groups on Sport |
42,748 | protected function doUpdateObjects ( Sport $ model , $ data ) { ObjectQuery :: create ( ) -> filterBySport ( $ model ) -> delete ( ) ; $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Object' ; } else { $ related = ObjectQuery :: create ( ) -> findOneById ( $ entry [ 'id' ] ) ; $ model -> addObject ( $ related ) ; } } if ( count ( $ errors ) > 0 ) { throw new ErrorsException ( $ errors ) ; } } | Internal update mechanism of Objects on Sport |
42,749 | protected function doUpdatePositions ( Sport $ model , $ data ) { PositionQuery :: create ( ) -> filterBySport ( $ model ) -> delete ( ) ; $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Position' ; } else { $ related = PositionQuery :: create ( ) -> findOneById ( $ entry [ 'id' ] ) ; $ model -> addPosition ( $ related ) ; } } if ( count ( $ errors ) > 0 ) { throw new ErrorsException ( $ errors ) ; } } | Internal update mechanism of Positions on Sport |
42,750 | protected function doUpdateSkills ( Sport $ model , $ data ) { SkillQuery :: create ( ) -> filterBySport ( $ model ) -> delete ( ) ; $ errors = [ ] ; foreach ( $ data as $ entry ) { if ( ! isset ( $ entry [ 'id' ] ) ) { $ errors [ ] = 'Missing id for Skill' ; } else { $ related = SkillQuery :: create ( ) -> findOneById ( $ entry [ 'id' ] ) ; $ model -> addSkill ( $ related ) ; } } if ( count ( $ errors ) > 0 ) { throw new ErrorsException ( $ errors ) ; } } | Internal update mechanism of Skills on Sport |
42,751 | protected function get ( $ id ) { if ( $ this -> pool === null ) { $ this -> pool = new Map ( ) ; } else if ( $ this -> pool -> has ( $ id ) ) { return $ this -> pool -> get ( $ id ) ; } $ model = SportQuery :: create ( ) -> findOneById ( $ id ) ; $ this -> pool -> set ( $ id , $ model ) ; return $ model ; } | Returns one Sport with the given id from cache |
42,752 | public function addErrors ( ErrorResourceInterface ... $ errors ) : void { $ this -> errors = array_merge ( $ this -> errors , $ errors ) ; } | Add errors to collection |
42,753 | public function push ( ... $ items ) : Stack { $ values = $ this -> _pushAll ( $ items ) ; $ this -> setValues ( $ values ) ; return $ this ; } | Push item to the top of stack |
42,754 | public function getAll ( ) : iterable { if ( $ this -> permissions === null ) { $ list = app ( ) -> getCollector ( ) -> collect ( 'permissions' ) -> get ( ) ; $ key = 0 ; $ names = [ ] ; $ permissions = [ ] ; foreach ( $ list as $ name => $ description ) { $ permissions [ ] = new Permission ( $ name , $ description ) ; $ names [ $ name ] = $ key ; $ key ++ ; } $ this -> permissions = $ permissions ; $ this -> names = $ names ; } return $ this -> permissions ; } | Get all permissions |
42,755 | public function getByName ( string $ name ) : ? IPermission { if ( $ this -> permissions === null ) { $ this -> getAll ( ) ; } if ( ! isset ( $ this -> names [ $ name ] ) ) { return null ; } return $ this -> permissions [ $ this -> names [ $ name ] ] ; } | Get permission by its name |
42,756 | public function getMultipleByName ( array $ permissions ) : array { if ( $ this -> permissions === null ) { $ this -> getAll ( ) ; } $ results = [ ] ; foreach ( $ permissions as $ permission ) { if ( isset ( $ this -> names [ $ permission ] ) ) { $ results [ ] = $ this -> permissions [ $ this -> names [ $ permission ] ] ; } } return $ results ; } | Get a permissions by their name |
42,757 | public function process ( ContainerBuilder $ container ) { $ this -> compiler = $ container -> getCompiler ( ) ; $ this -> formatter = $ this -> compiler -> getLoggingFormatter ( ) ; $ this -> graph = $ this -> compiler -> getServiceReferenceGraph ( ) ; $ container -> setDefinitions ( $ this -> inlineArguments ( $ container , $ container -> getDefinitions ( ) , true ) ) ; } | Processes the ContainerBuilder for inline service definitions . |
42,758 | private function inlineArguments ( ContainerBuilder $ container , array $ arguments , $ isRoot = false ) { foreach ( $ arguments as $ k => $ argument ) { if ( $ isRoot ) { $ this -> currentId = $ k ; } if ( is_array ( $ argument ) ) { $ arguments [ $ k ] = $ this -> inlineArguments ( $ container , $ argument ) ; } elseif ( $ argument instanceof Reference ) { if ( ! $ container -> hasDefinition ( $ id = ( string ) $ argument ) ) { continue ; } if ( $ this -> isInlineableDefinition ( $ id , $ definition = $ container -> getDefinition ( $ id ) ) ) { $ this -> compiler -> addLogMessage ( $ this -> formatter -> formatInlineService ( $ this , $ id , $ this -> currentId ) ) ; if ( $ definition -> isShared ( ) ) { $ arguments [ $ k ] = $ definition ; } else { $ arguments [ $ k ] = clone $ definition ; } } } elseif ( $ argument instanceof Definition ) { $ argument -> setArguments ( $ this -> inlineArguments ( $ container , $ argument -> getArguments ( ) ) ) ; $ argument -> setMethodCalls ( $ this -> inlineArguments ( $ container , $ argument -> getMethodCalls ( ) ) ) ; $ argument -> setProperties ( $ this -> inlineArguments ( $ container , $ argument -> getProperties ( ) ) ) ; $ configurator = $ this -> inlineArguments ( $ container , array ( $ argument -> getConfigurator ( ) ) ) ; $ argument -> setConfigurator ( $ configurator [ 0 ] ) ; $ factory = $ this -> inlineArguments ( $ container , array ( $ argument -> getFactory ( ) ) ) ; $ argument -> setFactory ( $ factory [ 0 ] ) ; } } return $ arguments ; } | Processes inline arguments . |
42,759 | private function send ( $ message ) { $ widget = new Widget ; $ templateParams = Json :: decode ( $ message -> packed_json_template_params ) ; return \ Yii :: $ app -> mailer -> compose ( $ message -> template -> body_view_file , $ templateParams ) -> setFrom ( Module :: module ( ) -> senderEmail ) -> setTo ( trim ( $ message -> email ) ) -> setSubject ( $ widget -> render ( $ message -> template -> subject_view_file , $ templateParams ) ) -> send ( ) ; } | Send the message via swift mailer |
42,760 | public function actionSend ( $ id ) { $ message = Message :: findOne ( $ id ) ; if ( $ message !== null ) { try { $ message -> status = $ this -> send ( $ message ) > 0 ? Message :: STATUS_SUCCESS : Message :: STATUS_ERROR ; $ message -> save ( true , [ 'status' ] ) ; } catch ( \ Exception $ e ) { $ message -> status = Message :: STATUS_ERROR ; $ message -> save ( true , [ 'status' ] ) ; $ this -> stderr ( $ e -> getMessage ( ) ) ; } } else { $ this -> stdout ( "Message not found\n" ) ; exit ( 1 ) ; } } | Send the message by id |
42,761 | public function sendFailed ( ) { $ messages = Message :: findAll ( [ 'status' => Message :: STATUS_ERROR ] ) ; foreach ( $ messages as $ message ) { try { $ message -> status = $ this -> send ( $ message ) > 0 ? Message :: STATUS_SUCCESS : Message :: STATUS_ERROR ; $ message -> save ( true , [ 'status' ] ) ; } catch ( \ Exception $ e ) { $ message -> status = Message :: STATUS_FATAL_ERROR ; $ message -> save ( true , [ 'status' ] ) ; $ this -> stderr ( $ e -> getMessage ( ) ) ; } } } | Send failed messages |
42,762 | public function render ( $ nameOrModel , array $ variables = [ ] ) { $ __module = null ; if ( $ nameOrModel instanceof ViewModelInterface ) { $ model = $ nameOrModel ; $ nameOrModel = $ model -> getTemplate ( ) ; $ __module = $ model -> getModule ( ) ; $ variables = array_merge ( $ model -> getVariables ( ) , $ variables ) ; unset ( $ model ) ; } elseif ( ! is_string ( $ nameOrModel ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid render source provided; must be a string or instance ' . 'of "%s", "%s" received.' , ViewModelInterface :: CLASS , is_object ( $ nameOrModel ) ? get_class ( $ nameOrModel ) : gettype ( $ nameOrModel ) ) ) ; } extract ( $ variables ) ; $ __old = $ this -> setVariables ( $ variables ) ; unset ( $ variables ) ; try { ob_start ( ) ; include $ this -> getResolver ( ) -> resolve ( $ nameOrModel , $ __module ) ; $ __return = ob_get_clean ( ) ; } catch ( Error $ e ) { ob_end_clean ( ) ; throw $ e ; } catch ( Exception $ e ) { ob_end_clean ( ) ; throw $ e ; } $ this -> setVariables ( $ __old ) ; return $ __return ; } | Renders the view model or template . |
42,763 | public static function create ( $ baseFolder = null , $ cropsFolder = null , $ adaptor = null ) { return new static ( $ baseFolder , $ cropsFolder , $ adaptor ) ; } | Staticly create instance |
42,764 | public function handle ( $ data = null ) { $ adaptor = $ this -> getAdaptor ( ) ; if ( $ adaptor ) { $ data = $ adaptor -> transform ( $ data , $ this ) ; } $ data = array_merge ( [ 'name' => null , 'width' => null , 'height' => null , 'focus_point_x' => 0 , 'focus_point_y' => 0 , 'resize' => false , ] , $ data ) ; extract ( $ data ) ; if ( ! $ name ) throw new \ Exception ( 'You need to set a name in adaptor' ) ; if ( ! $ width && ! $ height ) throw new \ Exception ( 'The width or the height need to be set' ) ; $ this -> handler = ImageHandler :: create ( $ name , $ this -> getBaseFolder ( ) , $ this -> getCropsFolder ( ) ) ; if ( $ resize || ( ! $ width || ! $ height ) ) { $ this -> handler -> resize ( $ width , $ height ) ; } else { $ this -> handler -> cropToFit ( $ width , $ height , $ focus_point_x , $ focus_point_y ) ; } return $ this ; } | Handle image based on array |
42,765 | public function getBaseFolder ( $ path = null ) { if ( $ path ) { return sprintf ( '%s/%s' , $ this -> baseFolder , $ path ) ; } return $ this -> baseFolder ; } | Getter for baseFolder |
42,766 | public function getCropsFolder ( $ path = null ) { if ( ! $ this -> cropsFolder ) { return $ this -> getBaseFolder ( $ path ) ; } if ( $ path ) { return sprintf ( '%s/%s' , $ this -> cropsFolder , basename ( $ path ) ) ; } return $ this -> cropsFolder ; } | Getter for cropsFolder |
42,767 | public function setAdaptor ( $ adaptor = null ) { $ this -> adaptor = $ adaptor ; if ( ! $ adaptor ) { return $ this ; } if ( ! ( $ adaptor instanceof CropAdaptorInterface ) ) { throw new \ Exception ( 'The adaptor need to implement LasseHaslev\Image\Adaptors\CropAdaptorInterface' ) ; } return $ this ; } | Setter for adaptor |
42,768 | public function getProvider ( ) : AbstractProvider { $ class = $ this -> providerClass ( ) ; return new $ class ( [ 'clientId' => $ this -> clientId , 'clientSecret' => $ this -> clientSecret , 'redirectUri' => $ this -> redirectUrl , ] ) ; } | Get a OAuthProvider . |
42,769 | public function bindIn ( $ token , $ array ) { $ bindString = "" ; foreach ( $ array as $ value ) { $ bindString .= ',:fautoIn' . ++ $ this -> whereInCount ; $ this -> bindValue ( ':fautoIn' . $ this -> whereInCount , $ value ) ; } $ this -> sqlString = str_replace ( $ token , ltrim ( $ bindString , "," ) , $ this -> sqlString ) ; return $ this ; } | binds an array of value . |
42,770 | public static function compareStr ( $ str1 , $ str2 ) { $ len1 = static :: binaryStrlen ( $ str1 ) ; $ len2 = static :: binaryStrlen ( $ str2 ) ; $ len = min ( $ len1 , $ len2 ) ; $ diff = $ len1 ^ $ len2 ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ diff |= ord ( $ str1 [ $ i ] ) ^ ord ( $ str2 [ $ i ] ) ; } return $ diff === 0 ; } | Constant time string comparison |
42,771 | public function validate ( ) { if ( $ this -> error ) { switch ( $ this -> error ) { case UPLOAD_ERR_INI_SIZE : case UPLOAD_ERR_FORM_SIZE : { throw new UserException ( 'fileTooBig' ) ; break ; } case UPLOAD_ERR_PARTIAL : case UPLOAD_ERR_NO_FILE : { throw new UserException ( 'transfertIssue' ) ; break ; } default : { log_error ( "Server upload error (error={$this->error}, name={$this->fileName})" , 'Uploading file' , false ) ; throw new UserException ( 'serverIssue' ) ; } } } if ( $ this -> expectedType !== NULL ) { if ( $ this -> getType ( ) !== $ this -> expectedType ) { throw new UserException ( 'invalidType' ) ; } } if ( $ this -> allowedExtensions !== NULL ) { $ ext = $ this -> getExtension ( ) ; if ( $ ext === $ this -> allowedExtensions || ( is_array ( $ this -> allowedExtensions ) && ! in_array ( $ ext , $ this -> allowedExtensions ) ) ) { throw new UserException ( 'invalidExtension' ) ; } } if ( $ this -> allowedMimeTypes !== NULL ) { $ mt = $ this -> getMIMEType ( ) ; if ( $ mt === $ this -> allowedMimeTypes || ( is_array ( $ this -> allowedMimeTypes ) && ! in_array ( $ mt , $ this -> allowedMimeTypes ) ) ) { throw new UserException ( 'invalidMimeType' ) ; } } } | Validate the input file is respecting upload restrictions |
42,772 | protected static function loadPath ( $ from , & $ files = array ( ) , $ path = '' ) { $ fileName = ( $ path === '' ) ? $ from [ 'name' ] : apath_get ( $ from [ 'name' ] , $ path ) ; if ( empty ( $ fileName ) ) { return $ files ; } if ( is_array ( $ fileName ) ) { if ( $ path !== '' ) { $ path .= '/' ; } foreach ( $ fileName as $ index => $ fn ) { static :: loadPath ( $ from , $ files , $ path . $ index ) ; } return $ files ; } apath_setp ( $ files , $ path , new static ( $ fileName , apath_get ( $ from , 'size/' . $ path ) , apath_get ( $ from , 'tmp_name/' . $ path ) , apath_get ( $ from , 'error/' . $ path ) ) ) ; return $ files ; } | Get uploaded file from path |
42,773 | protected function addIteratedValidationMessages ( $ attribute , $ messages = [ ] ) { foreach ( $ messages as $ field => $ message ) { $ field_name = $ attribute . $ field ; $ messages [ $ field_name ] = $ message ; } $ this -> setCustomMessages ( $ messages ) ; } | Add any custom messages for this ruleSet to the validator |
42,774 | public function setFor ( $ key , \ DateTime $ date , $ value ) { $ this -> data [ $ this -> keyFor ( $ key , $ date ) ] = $ value ; } | Set value for a key for a given date . |
42,775 | public function setForRange ( $ key , \ DateTime $ start , \ DateTime $ end , $ value ) { $ this -> data [ $ this -> keyForRange ( $ key , $ start , $ end ) ] = $ value ; } | Set value for a key for a given date range . |
42,776 | public function getFor ( $ key , \ DateTime $ date ) { if ( ! $ this -> hasFor ( $ key , $ date ) ) { return null ; } return $ this -> data [ $ this -> keyFor ( $ key , $ date ) ] ; } | Get value for a key for a given date . |
42,777 | public function getForRange ( $ key , \ DateTime $ start , \ DateTime $ end ) { if ( ! $ this -> hasForRange ( $ key , $ start , $ end ) ) { return null ; } return $ this -> data [ $ this -> keyForRange ( $ key , $ start , $ end ) ] ; } | Get value for a key for a given date range . |
42,778 | public function hasFor ( $ key , \ DateTime $ date ) { return array_key_exists ( $ this -> keyFor ( $ key , $ date ) , $ this -> data ) ; } | Determine if value exists for a given date . |
42,779 | public function hasForRange ( $ key , \ DateTime $ start , \ DateTime $ end ) { return array_key_exists ( $ this -> keyForRange ( $ key , $ start , $ end ) , $ this -> data ) ; } | Determine if value exists for a given date range . |
42,780 | protected function keyForRange ( $ key , \ DateTime $ start , \ DateTime $ end ) { return 'range:' . $ key . '_' . $ this -> dateString ( $ start ) . '_' . $ this -> dateString ( $ end ) ; } | Generate key for key and date range . |
42,781 | public function removeFor ( $ key , \ DateTime $ date ) { unset ( $ this -> data [ $ this -> keyFor ( $ key , $ date ) ] ) ; } | Remove value for a key for a given date . |
42,782 | public function removeForRange ( $ key , \ DateTime $ start , \ DateTime $ end ) { unset ( $ this -> data [ $ this -> keyForRange ( $ key , $ start , $ end ) ] ) ; } | Remove value for a key for a given date range . |
42,783 | protected function isTypeMatched ( $ class , array $ arguments ) { if ( empty ( $ arguments ) ) { return false ; } elseif ( null !== $ class ) { return is_a ( $ arguments [ 0 ] , $ class -> getName ( ) ) ; } else { return true ; } } | Try best to guess parameter and argument are the same type |
42,784 | protected function getCallableParameters ( callable $ callable ) { if ( is_array ( $ callable ) ) { $ reflector = new \ ReflectionClass ( $ callable [ 0 ] ) ; $ method = $ reflector -> getMethod ( $ callable [ 1 ] ) ; } elseif ( $ this -> isInvocable ( $ callable ) ) { $ reflector = new \ ReflectionClass ( $ callable ) ; $ method = $ reflector -> getMethod ( '__invoke' ) ; } else { $ method = new \ ReflectionFunction ( $ callable ) ; } return $ method -> getParameters ( ) ; } | Get callable parameters |
42,785 | protected function getObjectByClass ( $ classname ) { if ( $ this -> getResolver ( ) -> hasService ( $ classname ) ) { $ serviceId = ObjectResolver :: getServiceId ( $ classname ) ; return $ this -> getResolver ( ) -> get ( $ serviceId ) ; } throw new LogicException ( Message :: get ( Message :: DI_CLASS_UNKNOWN , $ classname ) , Message :: DI_CLASS_UNKNOWN ) ; } | Get an object base on provided classname or interface name |
42,786 | protected function mergeMethods ( $ nodeData ) { if ( empty ( $ nodeData ) || isset ( $ nodeData [ 0 ] ) ) { return ( array ) $ nodeData ; } $ result = [ ] ; foreach ( $ nodeData as $ data ) { $ result = array_merge ( $ result , $ data ) ; } return $ result ; } | Merge different sections of a node |
42,787 | protected function getCommonMethods ( ) { $ commNode = $ this -> getResolver ( ) -> getSectionId ( '' , 'common' ) ; return $ this -> mergeMethods ( $ this -> getResolver ( ) -> get ( $ commNode ) ) ; } | Get common methods |
42,788 | protected function getMessages ( $ shard_id = NULL , $ last_sequence_number = NULL ) : array { $ records = [ ] ; try { $ shard_iterator = $ this -> getInitialShardIterator ( $ shard_id , $ last_sequence_number ) ; } catch ( \ Exception $ e ) { $ this -> processError ( $ e , [ 'shard_id' => $ shard_id , 'last_sequence_number' => $ last_sequence_number , ] ) ; return $ records ; } do { $ has_records = FALSE ; try { $ res = $ this -> getClient ( ) -> getRecords ( [ 'Limit' => $ this -> batchSize , 'ShardIterator' => $ shard_iterator , 'StreamName' => $ this -> getStreamName ( ) , ] ) ; $ shard_iterator = $ res -> get ( 'NextShardIterator' ) ; $ behind_latest = $ res -> get ( 'MillisBehindLatest' ) ; foreach ( $ res -> search ( 'Records[].[SequenceNumber, Data]' ) as $ event ) { list ( $ sequence_number , $ message_data ) = $ event ; try { $ records [ $ sequence_number ] = $ this -> getMessageFactory ( ) -> unserialize ( $ message_data ) ; } catch ( \ Exception $ e ) { $ this -> processError ( $ e , $ event ) ; } $ has_records = TRUE ; } } catch ( \ Exception $ e ) { $ this -> processError ( $ e ) ; } } while ( ! empty ( $ shard_iterator ) && ! empty ( $ behind_latest ) && ! $ has_records ) ; if ( ! empty ( $ sequence_number ) ) { $ this -> lastSequenceNumber = $ sequence_number ; } if ( ! empty ( $ behind_latest ) ) { $ this -> lag = $ behind_latest ; } return $ records ; } | Do a single call to a Kinesis stream to get messages . |
42,789 | protected function getInitialShardIterator ( $ shard_id , $ starting_sequence_number = NULL ) { $ args = [ 'ShardId' => $ shard_id , 'StreamName' => $ this -> getStreamName ( ) , 'ShardIteratorType' => $ this -> initialShardIteratorType , ] ; if ( ! empty ( $ starting_sequence_number ) ) { $ args [ 'ShardIteratorType' ] = self :: ITERATOR_TYPE_AFTER_SEQUENCE_NUMBER ; $ args [ 'StartingSequenceNumber' ] = $ starting_sequence_number ; } $ res = $ this -> getClient ( ) -> getShardIterator ( $ args ) ; return $ res -> get ( 'ShardIterator' ) ; } | Gets the initial shard iterator . |
42,790 | protected function getShardIds ( ) : array { $ key = $ this -> getStreamName ( ) . '.shard_ids' ; if ( $ this -> cache -> has ( $ key ) ) { return $ this -> cache -> get ( $ key ) ; } $ res = $ this -> getClient ( ) -> describeStream ( [ 'StreamName' => $ this -> getStreamName ( ) ] ) ; $ shard_ids = $ res -> search ( 'StreamDescription.Shards[].ShardId' ) ; $ this -> cache -> set ( $ key , $ shard_ids , 86400 ) ; return $ shard_ids ; } | Gets shard ids . |
42,791 | public static function bootTaggable ( ) { static :: created ( function ( Model $ taggableModel ) { if ( $ taggableModel -> queuedTags ) { $ taggableModel -> tag ( $ taggableModel -> queuedTags ) ; $ taggableModel -> queuedTags = [ ] ; } } ) ; static :: deleted ( function ( Model $ taggableModel ) { $ taggableModel -> tags ( ) -> detach ( ) ; } ) ; } | Boot the taggable trait for a model . |
42,792 | public function tagsWithGroup ( string $ group = null ) : Collection { return $ this -> tags -> filter ( function ( Tag $ tag ) use ( $ group ) { return $ tag -> group === $ group ; } ) ; } | Filter tags with group . |
42,793 | public function hasTag ( $ tags ) : bool { if ( is_string ( $ tags ) ) { return $ this -> tags -> contains ( 'slug' , $ tags ) ; } if ( is_int ( $ tags ) ) { return $ this -> tags -> contains ( 'id' , $ tags ) ; } if ( $ tags instanceof Tag ) { return $ this -> tags -> contains ( 'slug' , $ tags -> slug ) ; } if ( is_array ( $ tags ) && isset ( $ tags [ 0 ] ) && is_string ( $ tags [ 0 ] ) ) { return ! $ this -> tags -> pluck ( 'slug' ) -> intersect ( $ tags ) -> isEmpty ( ) ; } if ( is_array ( $ tags ) && isset ( $ tags [ 0 ] ) && is_int ( $ tags [ 0 ] ) ) { return ! $ this -> tags -> pluck ( 'id' ) -> intersect ( $ tags ) -> isEmpty ( ) ; } if ( $ tags instanceof Collection ) { return ! $ tags -> intersect ( $ this -> tags -> pluck ( 'slug' ) ) -> isEmpty ( ) ; } return false ; } | Determine if the model has any the given tags . |
42,794 | protected function prepareTags ( $ tags ) { if ( is_string ( $ tags ) && mb_strpos ( $ tags , static :: getTagsDelimiter ( ) ) !== false ) { $ delimiter = preg_quote ( static :: getTagsDelimiter ( ) , '#' ) ; $ tags = array_map ( 'trim' , preg_split ( "#[{$delimiter}]#" , $ tags , - 1 , PREG_SPLIT_NO_EMPTY ) ) ; } return $ tags ; } | Prepare tag list . |
42,795 | protected function hydrateTags ( $ tags , bool $ createMissing = false ) : Collection { $ tags = static :: prepareTags ( $ tags ) ; $ isTagsStringBased = static :: isTagsStringBased ( $ tags ) ; $ isTagsIntBased = static :: isTagsIntBased ( $ tags ) ; $ field = $ isTagsStringBased ? 'slug' : 'id' ; $ className = static :: getTagClassName ( ) ; if ( $ isTagsStringBased && $ createMissing ) { return $ className :: findManyByNameOrCreate ( $ tags ) ; } return $ isTagsStringBased || $ isTagsIntBased ? $ className :: query ( ) -> whereIn ( $ field , ( array ) $ tags ) -> get ( ) : collect ( $ tags ) ; } | Hydrate tags . |
42,796 | public function index ( $ instances = "" , $ selfedit = "false" ) { $ this -> instances = $ instances ; $ this -> generatedCode = "" ; if ( $ instances ) { $ this -> export ( $ instances , $ selfedit ) ; } $ this -> content -> addFile ( dirname ( __FILE__ ) . "/../../../../views/exportForm.php" , $ this ) ; $ this -> template -> toHtml ( ) ; } | Admin page used to export instances . |
42,797 | public function export ( $ instances , $ selfedit = "false" ) { if ( $ selfedit == "true" ) { $ moufManager = MoufManager :: getMoufManager ( ) ; } else { $ moufManager = MoufManager :: getMoufManagerHiddenInstance ( ) ; } $ instancesList = explode ( "\n" , $ instances ) ; $ cleaninstancesList = array ( ) ; foreach ( $ instancesList as $ instance ) { $ instance = trim ( $ instance , "\r " ) ; if ( ! empty ( $ instance ) ) { $ cleaninstancesList [ ] = $ instance ; } } $ exportService = new ExportService ( ) ; $ this -> generatedCode = $ exportService -> export ( $ cleaninstancesList , $ moufManager ) ; } | This action generates the objects from the SQL query and creates a new SELECT instance . |
42,798 | public static function soap ( string $ login , string $ password ) : TurboSmsSoapAdapter { $ responseParser = ( new ResponseParserFactory ( ) ) -> create ( ) ; $ soapClient = ( new SoapClientFactory ( ) ) -> create ( ) ; $ configuration = new Configuration ( $ login , $ password ) ; $ authenticator = new TurboSmsSoapAuthenticator ( $ soapClient , $ configuration , $ responseParser ) ; return new TurboSmsSoapAdapter ( $ soapClient , $ responseParser , $ authenticator ) ; } | Create the SOAP adapter for TurboSMS |
42,799 | protected static function logError ( self $ e ) : void { if ( class_exists ( '\Osf\Log\LogProxy' ) ) { $ msg = get_class ( $ e ) . ' : ' . $ e -> getMessage ( ) ; try { \ Osf \ Log \ LogProxy :: log ( $ msg , $ e -> getLogLevel ( ) , 'PHPERR' , $ e -> getTraceAsString ( ) ) ; } catch ( \ Exception $ ex ) { file_put_contents ( sys_get_temp_dir ( ) . '/undisplayed-sma-errors.log' , date ( 'Ymd-His-' ) . $ ex -> getMessage ( ) , FILE_APPEND ) ; } } } | Error - > Osf \ Log \ LogProxy |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.