Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Refactor for removal of CMSForm class #23

Merged
merged 1 commit into from
Mar 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ before_script:
- composer self-update || true
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
- "if [ \"$BEHAT_TEST\" = \"\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/behat-extension,silverstripe/cms; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require silverstripe/behat-extension:~2,silverstripe/cms; fi"
- cd ~/builds/ss
- php ~/travis-support/travis_setup_selenium.php --if-env BEHAT_TEST
- php ~/travis-support/travis_setup_php54_webserver.php --if-env BEHAT_TEST
Expand Down
18 changes: 16 additions & 2 deletions code/controller/SiteConfigLeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,24 @@ public function getEditForm($id = null, $fields = null)
}

$actions = $siteConfig->getCMSActions();
$form = CMSForm::create(
$negotiator = $this->getResponseNegotiator();
/** @var Form $form */
$form = Form::create(
$this, 'EditForm', $fields, $actions, $validator
)->setHTMLID('Form_EditForm');
$form->setResponseNegotiator($this->getResponseNegotiator());
$form->setValidationResponseCallback(function() use ($negotiator, $form) {
$request = $this->getRequest();
if($request->isAjax() && $negotiator) {
$form->setupFormErrors();
$result = $form->forTemplate();

return $negotiator->respond($request, array(
'CurrentForm' => function() use($result) {
return $result;
}
));
}
});
$form->addExtraClass('cms-content center cms-edit-form');
$form->setAttribute('data-pjax-fragment', 'CurrentForm');

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"require": {
"silverstripe/framework": "^4.0"
},
"extra": {
"installer-name": "siteconfig"
"require-dev": {
"phpunit/PHPUnit": "~4.8"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reasoning behind removing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra was duplicated in composer.json and was being ignored. Look down the file a bit...

Also it's not needed. silverstripe/siteconfig is already named as siteconfig and doesn't need an alias.

},
"minimum-stability": "dev",
"autoload": {
Expand Down
6 changes: 0 additions & 6 deletions tests/behat/features/bootstrap/Context/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
use SilverStripe\BehatExtension\Context\BasicContext;
use SilverStripe\BehatExtension\Context\LoginContext;
use SilverStripe\BehatExtension\Context\FixtureContext;
use SilverStripe\Framework\Test\Behaviour\CmsFormsContext;
use SilverStripe\Framework\Test\Behaviour\CmsUiContext;
use SilverStripe\Cms\Test\Behaviour;

// PHPUnit
require_once 'PHPUnit/Autoload.php';
require_once 'PHPUnit/Framework/Assert/Functions.php';

/**
* Features context
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;

// PHPUnit
require_once 'PHPUnit/Autoload.php';
require_once 'PHPUnit/Framework/Assert/Functions.php';

/**
* Context used to create fixtures in the SilverStripe ORM.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;

// PHPUnit
require_once 'PHPUnit/Autoload.php';
require_once 'PHPUnit/Framework/Assert/Functions.php';

/**
* Context used to create fixtures in the SilverStripe ORM.
*/
Expand All @@ -26,7 +22,7 @@ class ThemeContext extends BehatContext

/**
* Create a test theme
*
*
* @Given /^a theme "(?<theme>[^"]+)"/
*/
public function stepCreateTheme($theme)
Expand All @@ -42,7 +38,7 @@ public function stepCreateTheme($theme)

/**
* Create a template within a test theme
*
*
* @Given /^a template "(?<template>[^"]+)" in theme "(?<theme>[^"]+)" with content "(?<content>[^"]+)"/
*/
public function stepCreateTemplate($template, $theme, $content)
Expand Down Expand Up @@ -86,7 +82,7 @@ protected function requireDir($dirname)

/**
* Clean up any theme manipulation
*
*
* @AfterScenario
*/
public function cleanThemesAfterScenario()
Expand Down