jouwweb/openprovider-bulk-toolkit

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (dev-master) of this package.

dev-master 2018-02-01 10:28 UTC

This package is auto-updated.

Last update: 2019-02-28 15:55:24 UTC


README

Toolkit containing functions that can be used to make changes to OpenProvider in bulk safely.

Features:

  • Change DNS entries in bulk

Example

We add an A record to all domains that already have an MX record:

class AddARecordToOnceHavingMx implements DnsTransformer
{
    public function transform($domain, array $records)
    {
        $mxRecord = $this->getMx($records);
        if (!$mxRecord) {
            return $records;
        }
        
        $records[] = new DnsRecord('A', 'extra', '1.2.3.4', null, 3600);
        
        return $records;
    }
    
    protected function getMx(array $records)
    {
        /** @var DnsRecord $record */
        foreach ($records as $record) {
            if ($record->getType() === 'MX' && $record->getName() === '') {
                return $record;
            }
        }

        return null;
    }
}

$openProviderService = new OpenProviderService('user', 'pass');
$dnTransformService = new DnsTransformService($openProviderService);
$dnsTransformService->transform(new AddARecordToOnceHavingMx);

License

Licended under the MIT License.