-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
134 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Ngtfkx\Laradeck\FormBuilder\Layouts; | ||
|
||
|
||
abstract class AbstractLayout | ||
{ | ||
/** | ||
* @var string $cssFramework Тип верстки. Допустимые значения: html, bootstrap3, bootstrap4 | ||
*/ | ||
protected $cssFramework; | ||
|
||
/** | ||
* @var string $orientation Тип верстки формы | ||
*/ | ||
protected $orientation; | ||
|
||
/** | ||
* @var string $formClasses Классы, которые надо назначить на форму | ||
*/ | ||
protected $formClasses = ''; | ||
|
||
abstract protected function setFormClasses(); | ||
|
||
/** | ||
* AbstractLayout constructor. | ||
* @param string $cssFramework | ||
* @param string $orientation | ||
*/ | ||
public function __construct(string $cssFramework = 'html', ?string $orientation = null) | ||
{ | ||
$this->cssFramework = $cssFramework; | ||
$this->orientation($orientation); | ||
} | ||
|
||
public function orientation(?string $orientation = null): self | ||
{ | ||
$this->orientation = $orientation; | ||
|
||
$this->setFormClasses(); | ||
|
||
return $this; | ||
} | ||
|
||
public function getFormClasses(): string | ||
{ | ||
return $this->formClasses; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Ngtfkx\Laradeck\FormBuilder\Layouts; | ||
|
||
|
||
class Bootstrap3 extends AbstractLayout | ||
{ | ||
protected $cssFramework = 'bootstrap3'; | ||
|
||
protected function setFormClasses() | ||
{ | ||
switch ($this->orientation) { | ||
case 'inline': | ||
$this->formClasses = 'form-inline'; | ||
break; | ||
case 'horizontal': | ||
$this->formClasses = 'form-horizontal'; | ||
break; | ||
default: | ||
break; | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Ngtfkx\Laradeck\FormBuilder\Layouts; | ||
|
||
|
||
class Html extends AbstractLayout | ||
{ | ||
protected $cssFramework = 'html'; | ||
|
||
protected function setFormClasses() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Ngtfkx\Laradeck\FormBuilder\Tests; | ||
|
||
use Tests\TestCase; | ||
use Illuminate\Foundation\Testing\DatabaseMigrations; | ||
use Illuminate\Foundation\Testing\DatabaseTransactions; | ||
|
||
class Bootstrap3Test extends TestCase | ||
{ | ||
public function testFormClasses() | ||
{ | ||
$this->assertContains(' class="form-inline"', '' . fb()->layout('bootstrap3', 'inline')->open()); | ||
} | ||
} |