File: /virtual/nagasaki/public_html/ec/src/Eccube/Form/Type/Admin/ChangePasswordType.php
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
*
* http://www.lockon.co.jp/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
namespace Eccube\Form\Type\Admin;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
use Symfony\Component\Validator\Constraints as Assert;
class ChangePasswordType extends AbstractType
{
private $app;
public function __construct($app)
{
$this->app = $app;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$app = $this->app;
$builder
->add('current_password', 'password', array(
'label' => '現在のパスワード',
'constraints' => array(
new Assert\NotBlank(),
new UserPassword(),
),
))
->add('change_password', 'repeated', array(
'first_options' => array(
'label' => '新しいパスワード',
),
'second_options' => array(
'label' => '新しいパスワード(確認)',
),
'constraints' => array(
new Assert\NotBlank(),
new Assert\Length(array(
'min' => $app['config']['password_min_len'],
'max' => $app['config']['password_max_len'],
)),
new Assert\Regex(array(
'pattern' => '/^[[:graph:][:space:]]+$/i',
'message' => 'form.type.graph.invalid',
)),
),
))
->addEventSubscriber(new \Eccube\Event\FormEventSubscriber());
;
}
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'admin_change_password';
}
}