PHP code example of germania-kg / fabrics

1. Go to this page and download the library: Download germania-kg/fabrics 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/ */

    

germania-kg / fabrics example snippets



namespace Germania\Fabrics;

interface FabricsClientInterface
{

    /**
     * Retrieve all fabrics belonging to the given collection.
     *
     * @param  string        $collection   URL slug of a Germania Fabrics Collection
     * @param  string|null   $search       Optional: search term
     * @param  string|null   $sort         Optional: sort by field(s), string or CSV string
     * @return iterable|FabricInterface[]  Iterable with FabricInterface instances
     */
    public function collection( string $collection, string $search = null, string $sort = null) : iterable;


    /**
     * Retrieves all fabric transparencies belonging to the given collection.
     *
     * @param  string        $collection   URL slug of a Germania Fabrics Collection
     * @return iterable|FabricInterface[]  Iterable with FabricInterface instances
     */
    public function collectionTransparencies( string $collection) : iterable;


    /**
     * Retrieves all color groups belonging to the given collection.
     *
     * @param  string        $collection   URL slug of a Germania Fabrics Collection
     * @return iterable|FabricInterface[]  Iterable with FabricInterface instances
     */
    public function collectionColors( string $collection) : iterable;


    /**
     * Retrieves a single fabric from a given collection.
     *
     * @param  string $collection     URL slug of a Germania Fabrics Collection
     * @param  string $fabric_number  Fabric number
     * @return FabricInterface
     */
    public function fabric( string $collection, string $fabric_number ) : FabricInterface;
}



use Germania\Fabrics\FabricFactory;

$factory = new FabricFactory;

$fabric = $factory( [
	'fabric_number' => "1234",
  'collection_slug' => "someCollection"
]);

use MyApp\SepcialFabric;
$factory = new FabricFactory( SepcialFabric::class );


use Germania\Fabrics\Fabric;
use Germania\Fabrics\FabricDecoratorAbstract;

class MyDecorator extends FabricDecoratorAbstract
{
  // ...
}

$fabric = new Fabric;
$my_fabric = new MyDecorator( $fabric );


use Germania\Fabrics\PhotoNotEmptyFilterIterator;
use Germania\Fabrics\SameValueFilterIterator,
use Germania\Fabrics\LieferbarFabricsFilterIterator;
use Germania\Fabrics\EnabledFabricsFilterIterator;


use Germania\Fabrics\PdoFabricsClient;

$pdo = ... // Your PDO handler
$fabrics_table = "germania_fabrics";
$colors_table = "germania_color_groups";
$fabrics_colors_table = "germania_fabrics_colors";
$logger = // optional

$client = new PdoFabricsClient(
  $pdo, 
  $fabrics_table, 
  $colors_table, 
  $fabrics_colors_table, 
  $logger);

$collections = $client->collections();
print_r($collections);

//ArrayIterator Object
//(
//    [storage:ArrayIterator:private] => Array
//        (
//            [duette2014] => Array
//                (
//                    [collection_slug] => duette2014
//                    [collection_name] => DU-2014
//                    [fabrics_count] => 33
//                )
//            [jalousie2016] => Array
//                (
//                    [collection_slug] => jalousie2016
//                    [collection_name] => JAL-2016
//                    [fabrics_count] => 177
//                )