DependencyInjection/Configuration.php
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* MIT license.
*/
namespace Mayeco\GoogleBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* @author Mario Young <maye.co@gmail.com>
* @link maye.co
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('mayeco_google');
$rootNode
->children()
->scalarNode('user_agent')
->cannotBeEmpty()
->defaultValue('mayeco_google_bundle')
->end()
->arrayNode('oauth_info')
->isRequired()
->addDefaultsIfNotSet()
->children()
->scalarNode('client_id')
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode('client_secret')
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode('redirect_url')
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode('access_type')
->cannotBeEmpty()
->defaultValue('offline')
->validate()
->ifNotInArray(array('offline', 'online'))
->thenInvalid('Invalid access type %s')
->end()
->end()
->scalarNode('approval_prompt')
->cannotBeEmpty()
->defaultValue('force')
->validate()
->ifNotInArray(array('auto', 'force'))
->thenInvalid('Invalid approval prompt %s')
->end()
->end()
->end()
->end()
->arrayNode('adwords')
->isRequired()
->addDefaultsIfNotSet()
->children()
->scalarNode('dev_token')
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode('lib_version')
->cannotBeEmpty()
->defaultValue('v201702')
->validate()
->ifNotInArray(array('v201609', 'v201702'))
->thenInvalid('Invalid Adwords API version %s')
->end()
->end()
->end()
->end()
->end()
;
return $treeBuilder;
}
}