"Fossies" - the Fresh Open Source Software Archive

Member "framework-8.65.0/src/Illuminate/View/AnonymousComponent.php" (19 Oct 2021, 1172 Bytes) of package /linux/www/laravel-framework-8.65.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AnonymousComponent.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Illuminate\View;
    4 
    5 class AnonymousComponent extends Component
    6 {
    7     /**
    8      * The component view.
    9      *
   10      * @var string
   11      */
   12     protected $view;
   13 
   14     /**
   15      * The component data.
   16      *
   17      * @var array
   18      */
   19     protected $data = [];
   20 
   21     /**
   22      * Create a new anonymous component instance.
   23      *
   24      * @param  string  $view
   25      * @param  array  $data
   26      * @return void
   27      */
   28     public function __construct($view, $data)
   29     {
   30         $this->view = $view;
   31         $this->data = $data;
   32     }
   33 
   34     /**
   35      * Get the view / view contents that represent the component.
   36      *
   37      * @return string
   38      */
   39     public function render()
   40     {
   41         return $this->view;
   42     }
   43 
   44     /**
   45      * Get the data that should be supplied to the view.
   46      *
   47      * @return array
   48      */
   49     public function data()
   50     {
   51         $this->attributes = $this->attributes ?: $this->newAttributeBag();
   52 
   53         return array_merge(
   54             optional($this->data['attributes'] ?? null)->getAttributes() ?: [],
   55             $this->attributes->getAttributes(),
   56             $this->data,
   57             ['attributes' => $this->attributes]
   58         );
   59     }
   60 }