idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
52,800 | protected function matchAny ( array $ types ) { if ( ! $ this -> lexer -> isNextAny ( $ types ) ) { $ this -> syntaxError ( 'any of ' . implode ( ' or ' , array_map ( array ( $ this -> lexer , 'getName' ) , $ types ) ) ) ; } $ this -> lexer -> moveNext ( ) ; return $ this -> lexer -> token [ 0 ] ; } | Matches any of the passed tokens and returns the matched token s value . |
52,801 | protected function syntaxError ( $ expectedDesc , $ actualToken = null ) { if ( null === $ actualToken ) { $ actualToken = $ this -> lexer -> next ; } if ( null === $ actualToken ) { $ actualDesc = 'end of input' ; } else if ( $ actualToken [ 1 ] === 0 ) { $ actualDesc = sprintf ( '"%s" of type %s at beginning of input... | Raises a syntax error exception . |
52,802 | public function getName ( $ type ) { $ ref = new \ ReflectionClass ( $ this ) ; foreach ( $ ref -> getConstants ( ) as $ name => $ value ) { if ( $ value === $ type ) { return $ name ; } } throw new \ InvalidArgumentException ( sprintf ( 'There is no token with value %s.' , json_encode ( $ type ) ) ) ; } | Returns the name of the given token . |
52,803 | public function moveNext ( ) { $ this -> peek = 0 ; $ this -> token = $ this -> next ; $ this -> next = isset ( $ this -> tokens [ ++ $ this -> i ] ) ? $ this -> tokens [ $ this -> i ] : null ; return null !== $ this -> next ; } | Moves the pointer one token forward . |
52,804 | public function skipUntil ( $ type ) { while ( ! $ this -> isNext ( $ type ) && $ this -> moveNext ( ) ) ; if ( ! $ this -> isNext ( $ type ) ) { throw new \ RuntimeException ( sprintf ( 'Could not find the token %s.' , $ this -> getName ( $ type ) ) ) ; } } | Skips the token stream until a token of the given type . |
52,805 | public function onPostListQueryBuilder ( GenericEvent $ event ) { $ queryBuilder = $ event -> getArgument ( 'query_builder' ) ; if ( $ event -> hasArgument ( 'request' ) ) { $ this -> applyRequestFilters ( $ queryBuilder , $ event -> getArgument ( 'request' ) -> get ( 'filters' , [ ] ) ) ; } if ( $ event -> hasArgument... | Called on POST_LIST_QUERY_BUILDER event . |
52,806 | public function onPostSearchQueryBuilder ( GenericEvent $ event ) { $ queryBuilder = $ event -> getArgument ( 'query_builder' ) ; if ( $ event -> hasArgument ( 'request' ) ) { $ this -> applyRequestFilters ( $ queryBuilder , $ event -> getArgument ( 'request' ) -> get ( 'filters' , [ ] ) ) ; } } | Called on POST_SEARCH_QUERY_BUILDER event . |
52,807 | protected function applyRequestFilters ( QueryBuilder $ queryBuilder , array $ filters = [ ] ) { foreach ( $ filters as $ field => $ value ) { if ( '' === $ value || \ is_int ( $ field ) ) { continue ; } $ operator = \ is_array ( $ value ) ? ListFilter :: OPERATOR_IN : ListFilter :: OPERATOR_EQUALS ; $ listFilter = Lis... | Applies request filters on queryBuilder . |
52,808 | protected function applyFormFilters ( QueryBuilder $ queryBuilder , array $ filters = [ ] ) { foreach ( $ filters as $ field => $ listFilter ) { if ( null === $ listFilter ) { continue ; } $ this -> filterQueryBuilder ( $ queryBuilder , $ field , $ listFilter ) ; } } | Applies form filters on queryBuilder . |
52,809 | protected function isFilterAppliable ( QueryBuilder $ queryBuilder , string $ field ) : bool { $ qbClone = clone $ queryBuilder ; try { $ qbClone -> andWhere ( $ field . ' IS NULL' ) ; $ qbClone -> getQuery ( ) -> getSQL ( ) ; } catch ( QueryException $ e ) { return false ; } return true ; } | Checks if filter is directly appliable on queryBuilder . |
52,810 | public function checksUserAccess ( array $ entityConfig , string $ actionName , $ subject = null ) { if ( $ this -> adminMinimumRole && ! $ this -> authorizationChecker -> isGranted ( $ this -> adminMinimumRole ) ) { throw new AccessDeniedException ( \ sprintf ( 'You must be granted %s role to access admin !' , $ this ... | Throws an error if user has no access to the entity action . |
52,811 | public function isEasyAdminGranted ( array $ entityConfig , string $ actionName , $ subject = null ) { try { $ this -> checksUserAccess ( $ entityConfig , $ actionName , $ subject ) ; } catch ( AccessDeniedException $ e ) { return false ; } return true ; } | Returns user access as boolean no exception thrown . |
52,812 | private function processCustomShowTypes ( array $ backendConfig ) { foreach ( $ backendConfig [ 'entities' ] as $ entityName => $ entityConfig ) { foreach ( $ entityConfig [ 'show' ] [ 'fields' ] as $ fieldName => $ fieldMetadata ) { if ( \ array_key_exists ( $ fieldMetadata [ 'type' ] , static :: $ mapTypeToTemplates ... | Process custom types for SHOW view . |
52,813 | public static function getOperatorsList ( ) { if ( null === static :: $ operatorValues ) { static :: $ operatorValues = [ ] ; $ refClass = new \ ReflectionClass ( static :: class ) ; $ classConstants = $ refClass -> getConstants ( ) ; $ className = $ refClass -> getShortName ( ) ; $ constantPrefix = 'OPERATOR_' ; forea... | Returns operators list . |
52,814 | private function ensureFieldConfigurationIsValid ( array $ entityConfig , string $ entityName , string $ section ) { if ( ! isset ( $ entityConfig [ $ section ] [ 'fields' ] ) || ! \ count ( $ entityConfig [ $ section ] [ 'fields' ] ) ) { return ; } throw new ConflictingConfigurationException ( \ sprintf ( '"%s" and "%... | Explicit fields option and exclude_fields won t work together |
52,815 | protected function newAjaxAction ( ) { $ this -> dispatch ( EasyAdminEvents :: PRE_NEW ) ; $ entity = $ this -> executeDynamicMethod ( 'createNew<EntityName>Entity' ) ; $ easyadmin = \ array_merge ( $ this -> request -> attributes -> get ( 'easyadmin' ) , [ 'item' => $ entity ] ) ; $ this -> request -> attributes -> se... | The method that is executed when the user performs a new ajax action on an entity . |
52,816 | public function getEntityFqcnFromParent ( string $ parentFqcn , string $ parentProperty ) { $ parentClassMetadata = $ this -> doctrine -> getManagerForClass ( $ parentFqcn ) -> getClassMetadata ( $ parentFqcn ) ; if ( ! $ parentClassMetadata instanceof ClassMetadataInfo ) { return ; } try { $ entityFqcn = $ parentClass... | Returns EasyAdmin entity entry name for a parent FQCN and property for embedded list . |
52,817 | public function guessEntityEntry ( string $ entityFqcn ) { $ matchingEntityConfigs = \ array_filter ( $ this -> easyAdminConfig [ 'entities' ] , function ( $ entityConfig ) use ( $ entityFqcn ) { return $ entityFqcn === $ entityConfig [ 'class' ] ; } ) ; if ( empty ( $ matchingEntityConfigs ) ) { throw new \ RuntimeExc... | Returns EasyAdmin entity entry name for a FQCN . |
52,818 | public function guessDefaultFilter ( string $ entityFqcn , string $ parentEntityProperty , $ parentEntity ) { $ entityClassMetadata = $ this -> doctrine -> getManagerForClass ( $ entityFqcn ) -> getClassMetadata ( $ entityFqcn ) ; if ( ! $ entityClassMetadata instanceof ClassMetadataInfo ) { return [ ] ; } $ entityAsso... | Returns default filter for embeddedList . |
52,819 | private function addRegisterMappingsPass ( ContainerBuilder $ container ) { $ easyAdminExtensionBundleRefl = new \ ReflectionClass ( $ this ) ; if ( $ easyAdminExtensionBundleRefl -> isUserDefined ( ) ) { $ easyAdminExtensionBundlePath = \ dirname ( ( string ) $ easyAdminExtensionBundleRefl -> getFileName ( ) ) ; $ eas... | Register storage mapping for model - based persisted objects from EasyAdminExtension . Much inspired from FOSUserBundle implementation . |
52,820 | public static function defineDirectoryStructure ( Event $ event ) { $ options = static :: getOptions ( $ event ) ; if ( ! getenv ( 'SENSIOLABS_ENABLE_NEW_DIRECTORY_STRUCTURE' ) || ! $ event -> getIO ( ) -> askConfirmation ( 'Would you like to use Symfony 3 directory structure? [y/N] ' , false ) ) { return ; } $ rootDir... | Asks if the new directory structure should be used installs the structure if needed . |
52,821 | public static function buildBootstrap ( Event $ event ) { $ options = static :: getOptions ( $ event ) ; $ bootstrapDir = $ autoloadDir = $ options [ 'symfony-app-dir' ] ; if ( static :: useNewDirectoryStructure ( $ options ) ) { $ bootstrapDir = $ options [ 'symfony-var-dir' ] ; if ( ! static :: hasDirectory ( $ event... | Builds the bootstrap file . |
52,822 | public static function installAssets ( Event $ event ) { $ options = static :: getOptions ( $ event ) ; $ consoleDir = static :: getConsoleDir ( $ event , 'install assets' ) ; if ( null === $ consoleDir ) { return ; } $ webDir = $ options [ 'symfony-web-dir' ] ; $ symlink = '' ; if ( 'symlink' == $ options [ 'symfony-a... | Installs the assets under the web root directory . |
52,823 | public static function installRequirementsFile ( Event $ event ) { $ options = static :: getOptions ( $ event ) ; $ appDir = $ options [ 'symfony-app-dir' ] ; $ fs = new Filesystem ( ) ; $ newDirectoryStructure = static :: useNewDirectoryStructure ( $ options ) ; if ( ! $ newDirectoryStructure ) { if ( ! static :: hasD... | Updated the requirements file . |
52,824 | protected function validateSchema ( & $ document_data , & $ data , array $ data_pointer , array $ parent_data_pointer , ISchema $ document , $ schema , ValidationResult $ bag ) : bool { if ( is_bool ( $ schema ) ) { if ( $ schema ) { return true ; } $ bag -> addError ( new ValidationError ( $ data , $ data_pointer , $ ... | Validates a schema |
52,825 | protected function validateKeywords ( & $ document_data , & $ data , array $ data_pointer , array $ parent_data_pointer , ISchema $ document , $ schema , ValidationResult $ bag ) : bool { $ defaults = null ; if ( $ this -> defaultSupport && is_object ( $ data ) && is_object ( $ schema ) && property_exists ( $ schema , ... | Validates schema keywords |
52,826 | protected function validateProperties ( & $ document_data , & $ data , array $ data_pointer , array $ parent_data_pointer , ISchema $ document , $ schema , ValidationResult $ bag , array $ defaults = null ) : bool { $ type = $ this -> helper -> type ( $ data , true ) ; if ( $ type === 'null' || $ type === 'boolean' ) {... | Validates keywords based on data type |
52,827 | protected function deepClone ( $ vars ) { if ( is_object ( $ vars ) ) { $ vars = get_object_vars ( $ vars ) ; foreach ( $ vars as $ key => $ value ) { if ( is_array ( $ value ) || is_object ( $ value ) ) { $ vars [ $ key ] = $ this -> deepClone ( $ value ) ; } unset ( $ value ) ; } return ( object ) $ vars ; } if ( ! i... | Clones a variable in depth |
52,828 | public function getFlashMessages ( $ type , $ domain = null ) { @ trigger_error ( 'Method "FlashMessageExtension::getFlashMessages()" is deprecated since SonataCoreBundle 3.11.0 and will' . ' be removed in 4.0. Use the FlashMessageRuntime instead.' , E_USER_DEPRECATED ) ; return $ this -> flashManager -> get ( $ type ,... | Returns flash messages handled by Sonata core flash manager . |
52,829 | protected function getValue ( ) { if ( '' === $ this -> current ) { return $ this -> subject ; } $ propertyAccessor = PropertyAccess :: createPropertyAccessor ( ) ; return $ propertyAccessor -> getValue ( $ this -> subject , $ this -> getCurrentPropertyPath ( ) ) ; } | Return the value linked to . |
52,830 | public function serializeObjectToId ( VisitorInterface $ visitor , $ data , array $ type , Context $ context ) { $ className = $ this -> manager -> getClass ( ) ; if ( $ data instanceof $ className ) { return $ visitor -> visitInteger ( $ data -> getId ( ) , $ type , $ context ) ; } } | Serialize data object to id . |
52,831 | public function get ( $ type , $ domain = null ) { $ this -> handle ( $ domain ) ; return $ this -> getSession ( ) -> getFlashBag ( ) -> get ( $ type ) ; } | Returns flash bag messages for correct type after renaming with Sonata core type . |
52,832 | protected function handle ( $ domain = null ) { foreach ( $ this -> getTypes ( ) as $ type => $ values ) { foreach ( $ values as $ value => $ options ) { $ domainType = $ domain ? : $ options [ 'domain' ] ; $ this -> rename ( $ type , $ value , $ domainType ) ; } } } | Handles flash bag types renaming . |
52,833 | protected function rename ( $ type , $ value , $ domain ) { $ flashBag = $ this -> getSession ( ) -> getFlashBag ( ) ; foreach ( $ flashBag -> get ( $ value ) as $ message ) { $ message = $ this -> getTranslator ( ) -> trans ( $ message , [ ] , $ domain ) ; $ flashBag -> add ( $ type , $ message ) ; } } | Process flash message type rename . |
52,834 | public function convert ( $ format ) { $ size = \ strlen ( $ format ) ; $ foundOne = false ; $ output = '' ; for ( $ i = 0 ; $ i < $ size ; ++ $ i ) { if ( "'" === $ format [ $ i ] ) { if ( 'T' === $ format [ $ i + 1 ] && '\'' === $ format [ $ i + 2 ] ) { $ output .= 'T' ; $ i += 2 ; } else { $ output .= '[' ; $ temp =... | Returns associated moment . js format . |
52,835 | private function dumpMetadata ( array $ metadata , InputInterface $ input , OutputInterface $ output ) { foreach ( $ metadata as $ name => $ meta ) { $ output -> writeln ( sprintf ( '<info>%s</info>' , $ name ) ) ; foreach ( $ meta [ 'fields' ] as $ fieldName => $ columnName ) { $ output -> writeln ( sprintf ( ' <comm... | Display the list of entities handled by Doctrine and their fields . |
52,836 | private function addFlashMessageSection ( ArrayNodeDefinition $ node ) { $ node -> children ( ) -> scalarNode ( 'form_type' ) -> defaultValue ( 'standard' ) -> validate ( ) -> ifNotInArray ( $ validFormTypes = [ 'standard' , 'horizontal' ] ) -> thenInvalid ( sprintf ( 'The form_type option value must be one of %s' , $ ... | Returns configuration for flash messages . |
52,837 | private function addSerializerFormats ( ArrayNodeDefinition $ node ) { $ node -> children ( ) -> arrayNode ( 'serializer' ) -> addDefaultsIfNotSet ( ) -> children ( ) -> arrayNode ( 'formats' ) -> prototype ( 'scalar' ) -> end ( ) -> defaultValue ( [ 'json' , 'xml' , 'yml' ] ) -> info ( 'Default serializer formats, wil... | Returns configuration for serializer formats . |
52,838 | public function registerFlashTypes ( ContainerBuilder $ container , array $ config ) { $ mergedConfig = array_merge_recursive ( $ config [ 'flashmessage' ] , [ 'success' => [ 'types' => [ 'success' => [ 'domain' => 'SonataCoreBundle' ] , 'sonata_flash_success' => [ 'domain' => 'SonataAdminBundle' ] , 'sonata_user_succe... | Registers flash message types defined in configuration to flash manager . |
52,839 | protected function getCommonDefaults ( ) { return [ 'widget' => 'single_text' , 'datepicker_use_button' => true , 'dp_pick_time' => true , 'dp_pick_date' => true , 'dp_use_current' => true , 'dp_min_date' => '1/1/1900' , 'dp_max_date' => null , 'dp_show_today' => true , 'dp_language' => $ this -> locale , 'dp_default_d... | Gets base default options for the date pickers . |
52,840 | private function isLegacyPipe ( $ resource ) { if ( \ PHP_VERSION_ID < 50428 || ( \ PHP_VERSION_ID >= 50500 && \ PHP_VERSION_ID < 50512 ) ) { $ meta = \ stream_get_meta_data ( $ resource ) ; if ( isset ( $ meta [ 'stream_type' ] ) && $ meta [ 'stream_type' ] === 'STDIO' ) { return true ; } } return false ; } | Returns whether this is a pipe resource in a legacy environment |
52,841 | protected function parseCallable ( $ method , $ callable ) { $ options = [ ] ; if ( is_array ( $ callable ) ) { $ options = $ callable ; if ( isset ( $ options [ 'callback' ] ) ) { $ callable = $ options [ 'callback' ] ; unset ( $ options [ 'callback' ] ) ; } else { $ callable = $ method ; } } if ( is_string ( $ callab... | Parse callable & options . |
52,842 | protected function handleTwigError ( Error $ ex ) { $ context = $ ex -> getSourceContext ( ) ; if ( null === $ context ) { throw $ ex ; } $ templateFile = $ context -> getPath ( ) ; $ templateLine = $ ex -> getTemplateLine ( ) ; if ( $ templateFile && file_exists ( $ templateFile ) ) { $ file = $ templateFile ; } elsei... | Handle a TwigError exception . |
52,843 | public function getFinder ( array $ paths ) { $ finder = ( empty ( $ this -> finder ) ) ? Finder :: create ( ) : $ this -> finder ; return $ finder -> files ( ) -> in ( $ paths ) -> name ( '*.' . $ this -> laravel [ 'twig.extension' ] ) ; } | Get a finder instance of Twig files in the specified directories . |
52,844 | protected function getFiles ( $ filename , array $ files , array $ directories ) { $ search = $ files ; $ paths = $ this -> laravel [ 'view' ] -> getFinder ( ) -> getPaths ( ) ; if ( ! empty ( $ filename ) ) { $ search [ ] = $ filename ; } if ( ! empty ( $ directories ) ) { $ search_directories = [ ] ; foreach ( $ dire... | Gets an array of files to lint . |
52,845 | protected function validate ( $ template , $ file = null ) { try { $ this -> twig -> parse ( $ this -> twig -> tokenize ( $ template , $ file ) ) ; } catch ( Error $ e ) { return [ 'template' => $ template , 'file' => $ file , 'valid' => false , 'exception' => $ e , ] ; } return [ 'template' => $ template , 'file' => $... | Validate the template . |
52,846 | protected function displayText ( array $ details , $ verbose = false ) { $ errors = 0 ; foreach ( $ details as $ info ) { if ( $ info [ 'valid' ] && $ verbose ) { $ file = ( $ info [ 'file' ] ) ? ' in ' . $ info [ 'file' ] : '' ; $ this -> line ( '<info>OK</info>' . $ file ) ; } elseif ( ! $ info [ 'valid' ] ) { $ erro... | Output the results as text . |
52,847 | protected function displayJson ( array $ details ) { $ errors = 0 ; array_walk ( $ details , function ( & $ info ) use ( & $ errors ) { $ info [ 'file' ] = ( string ) $ info [ 'file' ] ; unset ( $ info [ 'template' ] ) ; if ( ! $ info [ 'valid' ] ) { $ info [ 'message' ] = $ info [ 'exception' ] -> getMessage ( ) ; uns... | Output the results as json . |
52,848 | protected function renderException ( array $ info ) { $ file = $ info [ 'file' ] ; $ exception = $ info [ 'exception' ] ; $ line = $ exception -> getTemplateLine ( ) ; $ lines = $ this -> getContext ( $ info [ 'template' ] , $ line ) ; if ( $ file ) { $ this -> line ( sprintf ( '<error>Fail</error> in %s (line %s)' , $... | Output the error to the console . |
52,849 | public function isExpired ( $ path ) { $ time = filemtime ( $ this -> getCompiledPath ( $ path ) ) ; return $ this -> twig -> isTemplateFresh ( $ path , $ time ) ; } | Twig handles this for us . Here to satisfy interface . |
52,850 | protected function registerCommands ( ) { $ this -> app -> bindIf ( 'command.twig' , function ( ) { return new Command \ TwigBridge ; } ) ; $ this -> app -> bindIf ( 'command.twig.clean' , function ( ) { return new Command \ Clean ; } ) ; $ this -> app -> bindIf ( 'command.twig.lint' , function ( ) { return new Command... | Register console command bindings . |
52,851 | protected function registerOptions ( ) { $ this -> app -> bindIf ( 'twig.extension' , function ( ) { return $ this -> app [ 'config' ] -> get ( 'twigbridge.twig.extension' ) ; } ) ; $ this -> app -> bindIf ( 'twig.options' , function ( ) { $ options = $ this -> app [ 'config' ] -> get ( 'twigbridge.twig.environment' , ... | Register Twig config option bindings . |
52,852 | protected function registerEngine ( ) { $ this -> app -> bindIf ( 'twig' , function ( ) { $ extensions = $ this -> app [ 'twig.extensions' ] ; $ lexer = $ this -> app [ 'twig.lexer' ] ; $ twig = new Bridge ( $ this -> app [ 'twig.loader' ] , $ this -> app [ 'twig.options' ] , $ this -> app ) ; foreach ( $ extensions as... | Register Twig engine bindings . |
52,853 | public function findTemplate ( $ name ) { if ( $ this -> files -> exists ( $ name ) ) { return $ name ; } $ name = $ this -> normalizeName ( $ name ) ; if ( isset ( $ this -> cache [ $ name ] ) ) { return $ this -> cache [ $ name ] ; } try { $ this -> cache [ $ name ] = $ this -> finder -> find ( $ name ) ; } catch ( I... | Return path to template without the need for the extension . |
52,854 | protected function normalizeName ( $ name ) { if ( $ this -> files -> extension ( $ name ) === $ this -> extension ) { $ name = substr ( $ name , 0 , - ( strlen ( $ this -> extension ) + 1 ) ) ; } return $ name ; } | Normalize the Twig template name to a name the ViewFinder can use |
52,855 | public function setShortcuts ( array $ shortcuts ) { $ lowered = [ ] ; foreach ( $ shortcuts as $ from => $ to ) { $ lowered [ strtolower ( $ from ) ] = strtolower ( $ to ) ; } $ this -> shortcuts = $ lowered ; } | Set shortcuts to aliased classes . |
52,856 | public function getShortcut ( $ name ) { $ key = strtolower ( $ name ) ; return ( array_key_exists ( $ key , $ this -> shortcuts ) ) ? $ this -> shortcuts [ $ key ] : $ name ; } | Get the alias the shortcut points to . |
52,857 | public function getAliasParts ( $ name ) { if ( strpos ( $ name , '_' ) !== false ) { $ parts = explode ( '_' , $ name ) ; $ parts = array_filter ( $ parts ) ; if ( count ( $ parts ) < 2 ) { return false ; } return [ $ parts [ 0 ] , implode ( '_' , array_slice ( $ parts , 1 ) ) ] ; } return false ; } | Gets the class and method from the function name . |
52,858 | public function getLookup ( $ name ) { $ name = strtolower ( $ name ) ; return ( array_key_exists ( $ name , $ this -> lookup ) ) ? $ this -> lookup [ $ name ] : false ; } | Looks in the lookup cache for the function . |
52,859 | public function getFunction ( $ name ) { $ name = $ this -> getShortcut ( $ name ) ; if ( $ function = $ this -> getLookup ( $ name ) ) { return $ function ; } $ parts = $ this -> getAliasParts ( $ name ) ; if ( $ parts === false ) { return false ; } list ( $ class , $ method ) = $ parts ; $ class = strtolower ( $ clas... | Allow Twig to call Aliased function from an undefined function . |
52,860 | public function encode ( MessageInterface $ message ) { $ json = parent :: encode ( $ message ) ; return gzcompress ( $ json , $ this -> compressionLevel ) ; } | Encodes a given message |
52,861 | public function publish ( MessageInterface $ message ) { if ( count ( $ this -> transports ) == 0 ) { throw new RuntimeException ( "Publisher requires at least one transport" ) ; } $ reason = '' ; if ( ! $ this -> messageValidator -> validate ( $ message , $ reason ) ) { throw new RuntimeException ( "Message is invalid... | Publish a message over all defined transports |
52,862 | public function validate0100 ( MessageInterface $ message , & $ reason = "" ) { if ( self :: isEmpty ( $ message -> getHost ( ) ) ) { $ reason = "host not set" ; return false ; } if ( self :: isEmpty ( $ message -> getShortMessage ( ) ) ) { $ reason = "short-message not set" ; return false ; } if ( self :: isEmpty ( $ ... | Validates a message according to 1 . 0 standard |
52,863 | public function validate0101 ( MessageInterface $ message , & $ reason = "" ) { if ( ! $ this -> validate0100 ( $ message , $ reason ) ) { return false ; } foreach ( $ message -> getAllAdditionals ( ) as $ key => $ value ) { if ( ! preg_match ( '#^[\w\.\-]*$#' , $ key ) ) { $ reason = sprintf ( "additional key '%s' con... | Validates a message according to 1 . 1 standard |
52,864 | public function toStreamContext ( $ serverName = null ) { $ sslContext = array ( 'verify_peer' => ( bool ) $ this -> verifyPeer , 'allow_self_signed' => ( bool ) $ this -> allowSelfSigned ) ; if ( null !== $ this -> caFile ) { $ sslContext [ 'cafile' ] = $ this -> caFile ; } if ( null !== $ this -> ciphers ) { $ sslCon... | Returns a stream - context representation of this config |
52,865 | public static function fromUrl ( $ url , SslOptions $ sslOptions = null ) { $ parsed = parse_url ( $ url ) ; if ( false === $ parsed || ! isset ( $ parsed [ 'host' ] ) || ! isset ( $ parsed [ 'scheme' ] ) ) { throw new \ InvalidArgumentException ( "$url is not a valid URL" ) ; } $ scheme = strtolower ( $ parsed [ 'sche... | Creates a HttpTransport from a URI |
52,866 | public function setProxy ( $ proxyUri , $ requestFullUri = false ) { $ this -> proxyUri = $ proxyUri ; $ this -> requestFullUri = $ requestFullUri ; $ this -> socketClient -> setContext ( $ this -> getContext ( ) ) ; } | Enables HTTP proxy |
52,867 | public function log ( $ level , $ rawMessage , array $ context = array ( ) ) { $ message = $ this -> initMessage ( $ level , $ rawMessage , $ context ) ; if ( isset ( $ context [ 'exception' ] ) && $ context [ 'exception' ] instanceof Exception ) { $ this -> initExceptionData ( $ message , $ context [ 'exception' ] ) ;... | Publishes a given message and context with given level |
52,868 | protected function initMessage ( $ level , $ message , array $ context ) { $ message = ( string ) $ message ; $ context = $ this -> initContext ( $ context ) ; $ message = self :: interpolate ( $ message , $ context ) ; $ messageObj = new Message ( ) ; $ messageObj -> setLevel ( $ level ) ; $ messageObj -> setShortMess... | Initializes message - object |
52,869 | protected function initContext ( $ context ) { foreach ( $ context as $ key => & $ value ) { switch ( gettype ( $ value ) ) { case 'string' : case 'integer' : case 'double' : break ; case 'array' : case 'boolean' : $ value = json_encode ( $ value ) ; break ; case 'object' : if ( method_exists ( $ value , '__toString' )... | Initializes context array ensuring all values are string - safe |
52,870 | protected function initExceptionData ( Message $ message , Exception $ exception ) { $ message -> setLine ( $ exception -> getLine ( ) ) ; $ message -> setFile ( $ exception -> getFile ( ) ) ; $ longText = "" ; do { $ longText .= sprintf ( "%s: %s (%d)\n\n%s\n" , get_class ( $ exception ) , $ exception -> getMessage ( ... | Initializes Exceptiondata with given message |
52,871 | public function send ( Message $ message ) { try { return $ this -> transport -> send ( $ message ) ; } catch ( \ Exception $ e ) { $ this -> lastError = $ e ; return 0 ; } } | Sends a Message over this transport . |
52,872 | protected static function initSocket ( $ scheme , $ host , $ port , array $ context ) { $ socketDescriptor = sprintf ( "%s://%s:%d" , $ scheme , $ host , $ port ) ; $ socket = @ stream_socket_client ( $ socketDescriptor , $ errNo , $ errStr , static :: SOCKET_TIMEOUT , \ STREAM_CLIENT_CONNECT , stream_context_create ( ... | Initializes socket - client |
52,873 | public function write ( $ buffer ) { $ buffer = ( string ) $ buffer ; $ bufLen = Binary :: safeStrlen ( $ buffer ) ; $ socket = $ this -> getSocket ( ) ; $ written = 0 ; while ( $ written < $ bufLen ) { $ failed = false ; $ errorMessage = "Failed to write to socket" ; set_error_handler ( function ( $ errno , $ errstr )... | Writes a given string to the socket and returns the number of written bytes |
52,874 | public function close ( ) { if ( ! is_resource ( $ this -> socket ) ) { return ; } fclose ( $ this -> socket ) ; $ this -> socket = null ; } | Closes underlying socket explicitly |
52,875 | protected function publishConfig ( ) { $ this -> publishes ( [ __DIR__ . '/../../config/config.php' => config_path ( 'vat_calculator.php' ) , __DIR__ . '/../../public/js/vat_calculator.js' => public_path ( 'js/vat_calculator.js' ) , ] ) ; $ this -> publishes ( [ __DIR__ . '/../../public/js/vat_calculator.js' => base_pa... | Publish Teamwork configuration . |
52,876 | public function registerFacade ( ) { $ this -> app -> booting ( function ( ) { $ loader = \ Illuminate \ Foundation \ AliasLoader :: getInstance ( ) ; $ loader -> alias ( 'VatCalculator' , 'Mpociot\VatCalculator\Facades\VatCalculator' ) ; } ) ; } | Register the vault facade without the user having to add it to the app . php file . |
52,877 | private function getClientIP ( ) { if ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) && $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) { $ clientIpAddress = $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } elseif ( isset ( $ _SERVER [ 'REMOTE_ADDR' ] ) && $ _SERVER [ 'REMOTE_ADDR' ] ) { $ clientIpAddress = $ _SERVER [ 'REMOTE_ADDR' ... | Finds the client IP address . |
52,878 | public function getIPBasedCountry ( ) { $ ip = $ this -> getClientIP ( ) ; $ url = self :: GEOCODE_SERVICE_URL . $ ip ; $ result = file_get_contents ( $ url ) ; switch ( $ result [ 0 ] ) { case '1' : $ data = explode ( ';' , $ result ) ; return $ data [ 1 ] ; break ; default : return false ; } } | Returns the ISO 3166 - 1 alpha - 2 two letter country code for the client IP . If the IP can t be resolved it returns false . |
52,879 | public function shouldCollectVAT ( $ countryCode ) { $ taxKey = 'vat_calculator.rules.' . strtoupper ( $ countryCode ) ; return isset ( $ this -> taxRules [ strtoupper ( $ countryCode ) ] ) || ( isset ( $ this -> config ) && $ this -> config -> has ( $ taxKey ) ) ; } | Determines if you need to collect VAT for the given country code . |
52,880 | public function calculate ( $ netPrice , $ countryCode = null , $ postalCode = null , $ company = null , $ type = null ) { if ( $ countryCode ) { $ this -> setCountryCode ( $ countryCode ) ; } if ( $ postalCode ) { $ this -> setPostalCode ( $ postalCode ) ; } if ( ! is_null ( $ company ) && $ company !== $ this -> isCo... | Calculate the VAT based on the net price country code and indication if the customer is a company or not . |
52,881 | public function getTaxRateForCountry ( $ countryCode , $ company = false , $ type = null ) { return $ this -> getTaxRateForLocation ( $ countryCode , null , $ company , $ type ) ; } | Returns the tax rate for the given country code . This method is used to allow backwards compatibility . |
52,882 | public function getTaxRateForLocation ( $ countryCode , $ postalCode = null , $ company = false , $ type = null ) { if ( $ company && strtoupper ( $ countryCode ) !== strtoupper ( $ this -> businessCountryCode ) ) { return 0 ; } $ taxKey = 'vat_calculator.rules.' . strtoupper ( $ countryCode ) ; if ( isset ( $ this -> ... | Returns the tax rate for the given country code . If a postal code is provided it will try to lookup the different postal code exceptions that are possible . |
52,883 | public function getTaxRateForLocation ( $ countryCode = null , $ postalCode = null ) { return [ 'tax_rate' => $ this -> calculator -> getTaxRateForLocation ( $ countryCode , $ postalCode ) , ] ; } | Returns the tax rate for the given country code and postal code . |
52,884 | private function parseToken ( Request $ request ) : ? Token { $ cookies = $ request -> getCookieParams ( ) ; $ cookieName = $ this -> defaultCookie -> getName ( ) ; if ( ! isset ( $ cookies [ $ cookieName ] ) ) { return null ; } try { $ token = $ this -> tokenParser -> parse ( $ cookies [ $ cookieName ] ) ; } catch ( \... | Extract the token from the given request object |
52,885 | public function addOption ( $ value , string $ label ) : Menu { $ this -> addMenuItem ( new MenuOption ( $ value , $ label , function ( CliMenu $ menu ) { $ this -> result = $ menu -> getSelectedItem ( ) -> getValue ( ) ; $ menu -> close ( ) ; } ) ) ; return $ this ; } | Adds a new option . |
52,886 | public function addOptions ( array $ options ) : Menu { foreach ( $ options as $ value => $ label ) { $ this -> addOption ( $ value , $ label ) ; } return $ this ; } | Adds multiple options . |
52,887 | public function addQuestion ( string $ label , string $ placeholder = '' ) : Menu { $ itemCallable = function ( CliMenu $ menu ) use ( $ label , $ placeholder ) { $ result = $ menu -> askText ( ) -> setPromptText ( $ label ) -> setPlaceholderText ( $ placeholder ) -> ask ( ) ; $ this -> result = $ result -> fetch ( ) ;... | Add a question . |
52,888 | public function find ( $ expression ) { $ tokens = $ this -> parseTokens ( $ expression ) ; $ collectionData = [ $ this -> data ] ; foreach ( $ tokens as $ token ) { $ filter = $ token -> buildFilter ( $ this -> options ) ; $ filteredData = [ ] ; foreach ( $ collectionData as $ value ) { if ( AccessHelper :: isCollecti... | Evaluate an expression |
52,889 | public function last ( ) { $ keys = AccessHelper :: collectionKeys ( $ this -> data ) ; if ( empty ( $ keys ) ) { return null ; } $ value = $ this -> data [ end ( $ keys ) ] ? $ this -> data [ end ( $ keys ) ] : null ; return AccessHelper :: isCollectionType ( $ value ) ? new static ( $ value , $ this -> options ) : $ ... | Evaluate an expression and return the last result |
52,890 | public function firstKey ( ) { $ keys = AccessHelper :: collectionKeys ( $ this -> data ) ; if ( empty ( $ keys ) ) { return null ; } return $ keys [ 0 ] ; } | Evaluate an expression and return the first key |
52,891 | public function lastKey ( ) { $ keys = AccessHelper :: collectionKeys ( $ this -> data ) ; if ( empty ( $ keys ) || end ( $ keys ) === false ) { return null ; } return end ( $ keys ) ; } | Evaluate an expression and return the last key |
52,892 | public function renderPrivateResponse ( $ view , array $ parameters = [ ] , Response $ response = null ) { return $ this -> renderResponse ( $ view , $ parameters , $ response ) -> setTtl ( 0 ) -> setPrivate ( ) ; } | Returns a Response object that cannot be cacheable this must be used if the Response is related to the user . A good solution to make the page cacheable is to configure the block to be cached with javascript ... |
52,893 | protected function setDefaultExtraCacheKeys ( BlockContextInterface $ blockContext , array $ settings ) { if ( ! $ blockContext -> getSetting ( 'use_cache' ) || $ blockContext -> getSetting ( 'ttl' ) <= 0 ) { return ; } $ block = $ blockContext -> getBlock ( ) ; $ class = ClassUtils :: getClass ( $ block ) ; $ cacheSer... | Adds context settings to be able to rebuild a block context to the extra_cache_keys . |
52,894 | public function setDefaultFilter ( $ name ) { if ( ! \ array_key_exists ( $ name , $ this -> filters ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cannot set default exception filter "%s". It does not exist.' , $ name ) ) ; } $ this -> defaultFilter = $ name ; } | Sets the default filter name . |
52,895 | public function setDefaultRenderer ( $ name ) { if ( ! \ array_key_exists ( $ name , $ this -> renderers ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cannot set default exception renderer "%s". It does not exist.' , $ name ) ) ; } $ this -> defaultRenderer = $ name ; } | Sets the default renderer name . |
52,896 | public function getBlockRenderer ( BlockInterface $ block ) { $ type = $ block -> getType ( ) ; $ name = isset ( $ this -> blockRenderers [ $ type ] ) ? $ this -> blockRenderers [ $ type ] : $ this -> defaultRenderer ; $ service = $ this -> getRendererService ( $ name ) ; if ( ! $ service instanceof RendererInterface )... | Returns the exception renderer for given block . |
52,897 | public function getBlockFilter ( BlockInterface $ block ) { $ type = $ block -> getType ( ) ; $ name = isset ( $ this -> blockFilters [ $ type ] ) ? $ this -> blockFilters [ $ type ] : $ this -> defaultFilter ; $ service = $ this -> getFilterService ( $ name ) ; if ( ! $ service instanceof FilterInterface ) { throw new... | Returns the exception filter for given block . |
52,898 | protected function getFilterService ( $ name ) { if ( ! isset ( $ this -> filters [ $ name ] ) ) { throw new \ RuntimeException ( 'The filter "%s" does not exist.' ) ; } return $ this -> container -> get ( $ this -> filters [ $ name ] ) ; } | Returns the filter service for given filter name . |
52,899 | protected function getRendererService ( $ name ) { if ( ! isset ( $ this -> renderers [ $ name ] ) ) { throw new \ RuntimeException ( 'The renderer "%s" does not exist.' ) ; } return $ this -> container -> get ( $ this -> renderers [ $ name ] ) ; } | Returns the renderer service for given renderer name . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.