PHP code example of flamecore / synchronizer

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

    

flamecore / synchronizer example snippets


namespace Acme\MyApplication;

// To create a Synchronizer:
use FlameCore\Synchronizer\AbstractSynchronizer;
use FlameCore\Synchronizer\SynchronizerSourceInterface;
use FlameCore\Synchronizer\SynchronizerTargetInterface;

// To make your project compatible with Synchronizer:
use FlameCore\Synchronizer\SynchronizerInterface;


class ExampleSynchronizer extends AbstractSynchronizer
{
    /**
     * @param bool $preserve Preserve obsolete objects
     * @return bool Returns whether the synchronization succeeded.
     */
    public function synchronize($preserve = true)
    {
        // Do the sync magic

        return true;
    }

    /**
     * @param SynchronizerSourceInterface $source The source
     * @return bool Returns whether the synchronizer supports the source.
     */
    public function supportsSource(SynchronizerSourceInterface $source)
    {
        return $source instanceof ExampleSource;
    }

    /**
     * @param SynchronizerTargetInterface $target The target
     * @return bool Returns whether the synchronizer supports the target.
     */
    public function supportsTarget(SynchronizerTargetInterface $target)
    {
        return $target instanceof ExampleTarget;
    }
}

class ExampleSource implements SynchronizerSourceInterface
{
    /**
     * @param array $settings The settings
     */
    public function __construct(array $settings)
    {
        // Save settings
    }

    // Your methods...
}

class ExampleTarget implements SynchronizerTargetInterface
{
    /**
     * @param array $settings The settings
     */
    public function __construct(array $settings)
    {
        // Save settings
    }

    // Your methods...
}

class Application
{
    protected $synchronizer;

    public function setSynchronizer(SynchronizerInterface $synchronizer)
    {
        $this->synchronizer = $synchronizer;
    }

    // ...
}