Search
 
SCRIPT & CODE EXAMPLE
 

PHP

drupal 9 custom local stream wrapper

This is a modified snippet from a live real estate project to define a custom stream wrapper.

Add the stream wrapper as a service in your services YML file:

    stream_wrapper.pics:
      class: DrupalmymodPicsStreamWrapper
      tags:
        - { name: stream, scheme: pics }



Create the stream wrapper class extending LocalStream:

    <?php

    namespace Drupalmymod;

    use DrupalCoreStreamWrapperLocalStream;

    class PicsStreamWrapper extends LocalStream {

        public function getDirectoryPath() {
            return 'sites/default/files/pics';
        }

        public function getExternalUrl() {
            global $base_url;

            $path = str_replace('', '/', $this->getTarget());

            return $base_url . '/' . self::getDirectoryPath() . '/' . $path;
        }

        public function getName() {
            return 'Pics Stream';
        }

        public function getDescription() {
            return 'Pics stream for listing property pics.';
        }
    }


    
Comment

PREVIOUS NEXT
Code Example
Php :: dreamweaver laravel plugin 
Php :: multiply 
Php :: php square root 
Php :: Enqueue WP scripts and styles from a single action hook. 
Php :: jump to line phpstorm 
Php :: php make simple loop of number elevated to exponent without pow 
Php :: Display out of stock products last (even after sort) - Woocommerce 
Php :: larevel binance api 
Php :: get average of sql column php 
Php :: phpunit-watcher 
Php :: multi file delete in php 
Php :: php artisan insert user in database with tinker 
Php :: null safe operator in php 
Php :: simple php round When a negative value is passed as a parameter 
Php :: mamp change php version 
Php :: : in php 
Php :: php delete al lsession 
Php :: Funktion umgekehrt ausgeben, strrev 
Php :: How to add watermark in FPDF PHP - Parte 2 
Php :: delete request php-salesforce-rest-api 
Php :: hide extension 
Php :: DB::raw update query in laravel 
Php :: mkdir recursive php 
Php :: Laravel Auth successfully logged in but keep redirecting to login page and not showing failed error flash message 
Php :: Get page title, excerpt or content by id 
Php :: How to download file with laravel 
Php :: how to delete single row from grid in magento 
Php :: create request php-salesforce-rest-api 
Php :: laravel insert multiple rows from form 
Php :: magento update attribute value without using object manager 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =