PHP code example of sandstorm / lazydatasource

1. Go to this page and download the library: Download sandstorm/lazydatasource library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sandstorm / lazydatasource example snippets


    use Neos\Neos\Service\DataSource\AbstractDataSource;
    use Neos\ContentRepository\Domain\Model\NodeInterface;
    
    class MyLazyDataSource extends AbstractDataSource
    {
    
        use LazyDataSourceTrait;
    
        static protected $identifier = 'lazy-editor-test';
    
        protected function getDataForIdentifiers(array $identifiers, NodeInterface $node = null, array $arguments = [])
        {
            $options = [];
            foreach ($identifiers as $id) {
                $options[$id] = ['label' => 'My Label for ' . $id];
            }
            return $options;
        }
    
        protected function searchData(string $searchTerm, NodeInterface $node = null, array $arguments = [])
        {
            $options = [];
            $options['key'] = ['label' => 'My Label ' . $searchTerm];
            return $options;
        }
    }