From 8aaf7d66fb1aecccfcd4fc86aa34f063abd5a241 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Sat, 12 Jan 2019 10:57:14 -0600 Subject: [PATCH 1/3] Moved basics chapters into sub-folder and reformatted config file --- chapters/{ => basics}/abstract.md | 0 chapters/{ => basics}/arithmetic.md | 0 chapters/{ => basics}/arrays.md | 0 chapters/{ => basics}/basics.md | 0 chapters/{ => basics}/boolean-logic.md | 0 chapters/{ => basics}/classes-constructor.md | 0 chapters/{ => basics}/classes-inheritance.md | 0 chapters/{ => basics}/classes-visibility.md | 0 chapters/{ => basics}/classes.md | 0 chapters/{ => basics}/comparisons.md | 0 chapters/{ => basics}/conditionals.md | 0 chapters/{ => basics}/exceptions.md | 0 chapters/{ => basics}/functions.md | 0 chapters/{ => basics}/interfaces.md | 0 chapters/{ => basics}/loops.md | 0 chapters/{ => basics}/static.md | 0 chapters/{ => basics}/strings.md | 0 chapters/{ => basics}/variables.md | 0 config.php | 46 ++++++++++---------- src/Page.php | 12 ++--- 20 files changed, 29 insertions(+), 29 deletions(-) rename chapters/{ => basics}/abstract.md (100%) rename chapters/{ => basics}/arithmetic.md (100%) rename chapters/{ => basics}/arrays.md (100%) rename chapters/{ => basics}/basics.md (100%) rename chapters/{ => basics}/boolean-logic.md (100%) rename chapters/{ => basics}/classes-constructor.md (100%) rename chapters/{ => basics}/classes-inheritance.md (100%) rename chapters/{ => basics}/classes-visibility.md (100%) rename chapters/{ => basics}/classes.md (100%) rename chapters/{ => basics}/comparisons.md (100%) rename chapters/{ => basics}/conditionals.md (100%) rename chapters/{ => basics}/exceptions.md (100%) rename chapters/{ => basics}/functions.md (100%) rename chapters/{ => basics}/interfaces.md (100%) rename chapters/{ => basics}/loops.md (100%) rename chapters/{ => basics}/static.md (100%) rename chapters/{ => basics}/strings.md (100%) rename chapters/{ => basics}/variables.md (100%) diff --git a/chapters/abstract.md b/chapters/basics/abstract.md similarity index 100% rename from chapters/abstract.md rename to chapters/basics/abstract.md diff --git a/chapters/arithmetic.md b/chapters/basics/arithmetic.md similarity index 100% rename from chapters/arithmetic.md rename to chapters/basics/arithmetic.md diff --git a/chapters/arrays.md b/chapters/basics/arrays.md similarity index 100% rename from chapters/arrays.md rename to chapters/basics/arrays.md diff --git a/chapters/basics.md b/chapters/basics/basics.md similarity index 100% rename from chapters/basics.md rename to chapters/basics/basics.md diff --git a/chapters/boolean-logic.md b/chapters/basics/boolean-logic.md similarity index 100% rename from chapters/boolean-logic.md rename to chapters/basics/boolean-logic.md diff --git a/chapters/classes-constructor.md b/chapters/basics/classes-constructor.md similarity index 100% rename from chapters/classes-constructor.md rename to chapters/basics/classes-constructor.md diff --git a/chapters/classes-inheritance.md b/chapters/basics/classes-inheritance.md similarity index 100% rename from chapters/classes-inheritance.md rename to chapters/basics/classes-inheritance.md diff --git a/chapters/classes-visibility.md b/chapters/basics/classes-visibility.md similarity index 100% rename from chapters/classes-visibility.md rename to chapters/basics/classes-visibility.md diff --git a/chapters/classes.md b/chapters/basics/classes.md similarity index 100% rename from chapters/classes.md rename to chapters/basics/classes.md diff --git a/chapters/comparisons.md b/chapters/basics/comparisons.md similarity index 100% rename from chapters/comparisons.md rename to chapters/basics/comparisons.md diff --git a/chapters/conditionals.md b/chapters/basics/conditionals.md similarity index 100% rename from chapters/conditionals.md rename to chapters/basics/conditionals.md diff --git a/chapters/exceptions.md b/chapters/basics/exceptions.md similarity index 100% rename from chapters/exceptions.md rename to chapters/basics/exceptions.md diff --git a/chapters/functions.md b/chapters/basics/functions.md similarity index 100% rename from chapters/functions.md rename to chapters/basics/functions.md diff --git a/chapters/interfaces.md b/chapters/basics/interfaces.md similarity index 100% rename from chapters/interfaces.md rename to chapters/basics/interfaces.md diff --git a/chapters/loops.md b/chapters/basics/loops.md similarity index 100% rename from chapters/loops.md rename to chapters/basics/loops.md diff --git a/chapters/static.md b/chapters/basics/static.md similarity index 100% rename from chapters/static.md rename to chapters/basics/static.md diff --git a/chapters/strings.md b/chapters/basics/strings.md similarity index 100% rename from chapters/strings.md rename to chapters/basics/strings.md diff --git a/chapters/variables.md b/chapters/basics/variables.md similarity index 100% rename from chapters/variables.md rename to chapters/basics/variables.md diff --git a/config.php b/config.php index d764519..d54f873 100644 --- a/config.php +++ b/config.php @@ -44,116 +44,116 @@ return [ * */ 'pages' => [ - Page::create('index', 'index.phtml'), - Page::create('installing-php', 'installing-php.phtml'), - Page::create('credits', 'credits.phtml'), - Page::create('404', '404.phtml'), - Page::create('basics', null, 'basics.md', [ + Page::create('index', null, [], 'index.phtml'), + Page::create('installing-php', null, [], 'installing-php.phtml'), + Page::create('credits', null, [], 'credits.phtml'), + Page::create('404', null, [], '404.phtml'), + Page::create('basics', 'basics/basics.md', [ 'title' => 'Basics', 'subtitle' => 'Getting started', 'next' => 'variables', ]), - Page::create('variables', null, 'variables.md', [ + Page::create('variables', 'basics/variables.md', [ 'title' => 'Variables', 'subtitle' => 'The building blocks of PHP', 'previous' => 'basics', 'next' => 'arithmetic', ]), - Page::create('arithmetic', null, 'arithmetic.md', [ + Page::create('arithmetic', 'basics/arithmetic.md', [ 'title' => 'Arithmetic', 'subtitle' => 'Doing math like a pro', 'previous' => 'variables', 'next' => 'strings', ]), - Page::create('strings', null, 'strings.md', [ + Page::create('strings', 'basics/strings.md', [ 'title' => 'Strings', 'subtitle' => 'Working with text', 'previous' => 'arithmetic', 'next' => 'comparisons', ]), - Page::create('comparisons', null, 'comparisons.md', [ + Page::create('comparisons', 'basics/comparisons.md', [ 'title' => 'Comparisons', 'subtitle' => 'Equality checking', 'previous' => 'strings', 'next' => 'boolean-logic', ]), - Page::create('boolean-logic', null, 'boolean-logic.md', [ + Page::create('boolean-logic', 'basics/boolean-logic.md', [ 'title' => 'Boolean Logic', 'subtitle' => 'Is it a yes or a no?', 'previous' => 'comparisons', 'next' => 'conditionals', ]), - Page::create('conditionals', null, 'conditionals.md', [ + Page::create('conditionals', 'basics/conditionals.md', [ 'title' => 'Conditionals', 'subtitle' => 'Checking the if before the what', 'previous' => 'boolean-logic', 'next' => 'loops', ]), - Page::create('loops', null, 'loops.md', [ + Page::create('loops', 'basics/loops.md', [ 'title' => 'Loops', 'subtitle' => 'Increase your repetitions', 'previous' => 'conditionals', 'next' => 'arrays', ]), - Page::create('arrays', null, 'arrays.md', [ + Page::create('arrays', 'basics/arrays.md', [ 'title' => 'Arrays', 'subtitle' => 'Time to make a list', 'previous' => 'loops', 'next' => 'functions', ]), - Page::create('functions', null, 'functions.md', [ + Page::create('functions', 'basics/functions.md', [ 'title' => 'Functions', 'subtitle' => 'Reusable code', 'previous' => 'arrays', 'next' => 'classes', ]), - Page::create('classes', null, 'classes.md', [ + Page::create('classes', 'basics/classes.md', [ 'title' => 'Classes', 'subtitle' => 'Object-oriented programming', 'previous' => 'functions', 'next' => 'classes-inheritance', ]), - Page::create('classes-inheritance', null, 'classes-inheritance.md', [ + Page::create('classes-inheritance', 'basics/classes-inheritance.md', [ 'title' => 'Classes: Inheritance', 'subtitle' => 'Extend your objects', 'previous' => 'classes', 'next' => 'classes-visibility', ]), - Page::create('classes-visibility', null, 'classes-visibility.md', [ + Page::create('classes-visibility', 'basics/classes-visibility.md', [ 'title' => 'Classes: Visibility', 'subtitle' => 'Privatizing your objects', 'previous' => 'classes-inheritance', 'next' => 'classes-constructor', ]), - Page::create('classes-constructor', null, 'classes-constructor.md', [ + Page::create('classes-constructor', 'basics/classes-constructor.md', [ 'title' => 'Classes: Constructor', 'subtitle' => 'Construct your objects', 'previous' => 'classes-visibility', 'next' => 'static', ]), - Page::create('static', null, 'static.md', [ + Page::create('static', 'basics/static.md', [ 'title' => 'Static', 'subtitle' => 'Class properties and methods', 'previous' => 'classes-constructor', 'next' => 'interfaces', ]), - Page::create('interfaces', null, 'interfaces.md', [ + Page::create('interfaces', 'basics/interfaces.md', [ 'title' => 'Interfaces', 'subtitle' => 'Writing code contracts', 'previous' => 'static', 'next' => 'abstract', ]), - Page::create('abstract', null, 'abstract.md', [ + Page::create('abstract', 'basics/abstract.md', [ 'title' => 'Abstract Classes', 'subtitle' => 'Inheriting an interface', 'previous' => 'interfaces', 'next' => 'exceptions', ]), - Page::create('exceptions', null, 'exceptions.md', [ + Page::create('exceptions', 'basics/exceptions.md', [ 'title' => 'Exceptions', 'subtitle' => 'Throwing errors', 'previous' => 'abstract', - 'next' => '', + 'next' => 'web-http', ]), ], ]; diff --git a/src/Page.php b/src/Page.php index f2689f8..4dc3103 100644 --- a/src/Page.php +++ b/src/Page.php @@ -47,14 +47,14 @@ class Page */ public function __construct( string $name, - ?string $template = null, ?string $chapter = null, - ?array $variables = [] + ?array $variables = [], + ?string $template = null ) { $this->name = $name; - $this->template = $template; $this->chapter = $chapter; $this->variables = $variables; + $this->template = $template; } /** @@ -68,10 +68,10 @@ class Page */ public static function create( string $name, - ?string $template = null, ?string $chapter = null, - ?array $variables = [] + ?array $variables = [], + ?string $template = null ): Page { - return new static($name, $template, $chapter, $variables); + return new static($name, $chapter, $variables, $template); } } From 81a7371000f3ebff4d4f998a0119755bcdfd53a6 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Sat, 12 Jan 2019 15:33:19 -0600 Subject: [PATCH 2/3] Numbered basics chapters for sortability --- chapters/basics/{basics.md => 01-basics.md} | 0 .../basics/{variables.md => 02-variables.md} | 0 .../{arithmetic.md => 03-arithmetic.md} | 0 chapters/basics/{strings.md => 04-strings.md} | 0 .../{comparisons.md => 05-comparisons.md} | 0 .../{boolean-logic.md => 06-boolean-logic.md} | 0 .../{conditionals.md => 07-conditionals.md} | 0 chapters/basics/{loops.md => 08-loops.md} | 0 chapters/basics/{arrays.md => 09-arrays.md} | 0 .../basics/{functions.md => 10-functions.md} | 0 chapters/basics/{classes.md => 11-classes.md} | 0 ...heritance.md => 12-classes-inheritance.md} | 0 ...visibility.md => 13-classes-visibility.md} | 0 ...nstructor.md => 14-classes-constructor.md} | 0 chapters/basics/{static.md => 15-static.md} | 0 .../{interfaces.md => 16-interfaces.md} | 0 .../basics/{abstract.md => 17-abstract.md} | 0 .../{exceptions.md => 18-exceptions.md} | 0 config.php | 36 +++++++++---------- 19 files changed, 18 insertions(+), 18 deletions(-) rename chapters/basics/{basics.md => 01-basics.md} (100%) rename chapters/basics/{variables.md => 02-variables.md} (100%) rename chapters/basics/{arithmetic.md => 03-arithmetic.md} (100%) rename chapters/basics/{strings.md => 04-strings.md} (100%) rename chapters/basics/{comparisons.md => 05-comparisons.md} (100%) rename chapters/basics/{boolean-logic.md => 06-boolean-logic.md} (100%) rename chapters/basics/{conditionals.md => 07-conditionals.md} (100%) rename chapters/basics/{loops.md => 08-loops.md} (100%) rename chapters/basics/{arrays.md => 09-arrays.md} (100%) rename chapters/basics/{functions.md => 10-functions.md} (100%) rename chapters/basics/{classes.md => 11-classes.md} (100%) rename chapters/basics/{classes-inheritance.md => 12-classes-inheritance.md} (100%) rename chapters/basics/{classes-visibility.md => 13-classes-visibility.md} (100%) rename chapters/basics/{classes-constructor.md => 14-classes-constructor.md} (100%) rename chapters/basics/{static.md => 15-static.md} (100%) rename chapters/basics/{interfaces.md => 16-interfaces.md} (100%) rename chapters/basics/{abstract.md => 17-abstract.md} (100%) rename chapters/basics/{exceptions.md => 18-exceptions.md} (100%) diff --git a/chapters/basics/basics.md b/chapters/basics/01-basics.md similarity index 100% rename from chapters/basics/basics.md rename to chapters/basics/01-basics.md diff --git a/chapters/basics/variables.md b/chapters/basics/02-variables.md similarity index 100% rename from chapters/basics/variables.md rename to chapters/basics/02-variables.md diff --git a/chapters/basics/arithmetic.md b/chapters/basics/03-arithmetic.md similarity index 100% rename from chapters/basics/arithmetic.md rename to chapters/basics/03-arithmetic.md diff --git a/chapters/basics/strings.md b/chapters/basics/04-strings.md similarity index 100% rename from chapters/basics/strings.md rename to chapters/basics/04-strings.md diff --git a/chapters/basics/comparisons.md b/chapters/basics/05-comparisons.md similarity index 100% rename from chapters/basics/comparisons.md rename to chapters/basics/05-comparisons.md diff --git a/chapters/basics/boolean-logic.md b/chapters/basics/06-boolean-logic.md similarity index 100% rename from chapters/basics/boolean-logic.md rename to chapters/basics/06-boolean-logic.md diff --git a/chapters/basics/conditionals.md b/chapters/basics/07-conditionals.md similarity index 100% rename from chapters/basics/conditionals.md rename to chapters/basics/07-conditionals.md diff --git a/chapters/basics/loops.md b/chapters/basics/08-loops.md similarity index 100% rename from chapters/basics/loops.md rename to chapters/basics/08-loops.md diff --git a/chapters/basics/arrays.md b/chapters/basics/09-arrays.md similarity index 100% rename from chapters/basics/arrays.md rename to chapters/basics/09-arrays.md diff --git a/chapters/basics/functions.md b/chapters/basics/10-functions.md similarity index 100% rename from chapters/basics/functions.md rename to chapters/basics/10-functions.md diff --git a/chapters/basics/classes.md b/chapters/basics/11-classes.md similarity index 100% rename from chapters/basics/classes.md rename to chapters/basics/11-classes.md diff --git a/chapters/basics/classes-inheritance.md b/chapters/basics/12-classes-inheritance.md similarity index 100% rename from chapters/basics/classes-inheritance.md rename to chapters/basics/12-classes-inheritance.md diff --git a/chapters/basics/classes-visibility.md b/chapters/basics/13-classes-visibility.md similarity index 100% rename from chapters/basics/classes-visibility.md rename to chapters/basics/13-classes-visibility.md diff --git a/chapters/basics/classes-constructor.md b/chapters/basics/14-classes-constructor.md similarity index 100% rename from chapters/basics/classes-constructor.md rename to chapters/basics/14-classes-constructor.md diff --git a/chapters/basics/static.md b/chapters/basics/15-static.md similarity index 100% rename from chapters/basics/static.md rename to chapters/basics/15-static.md diff --git a/chapters/basics/interfaces.md b/chapters/basics/16-interfaces.md similarity index 100% rename from chapters/basics/interfaces.md rename to chapters/basics/16-interfaces.md diff --git a/chapters/basics/abstract.md b/chapters/basics/17-abstract.md similarity index 100% rename from chapters/basics/abstract.md rename to chapters/basics/17-abstract.md diff --git a/chapters/basics/exceptions.md b/chapters/basics/18-exceptions.md similarity index 100% rename from chapters/basics/exceptions.md rename to chapters/basics/18-exceptions.md diff --git a/config.php b/config.php index d54f873..dd6b642 100644 --- a/config.php +++ b/config.php @@ -48,108 +48,108 @@ return [ Page::create('installing-php', null, [], 'installing-php.phtml'), Page::create('credits', null, [], 'credits.phtml'), Page::create('404', null, [], '404.phtml'), - Page::create('basics', 'basics/basics.md', [ + Page::create('basics', 'basics/01-basics.md', [ 'title' => 'Basics', 'subtitle' => 'Getting started', 'next' => 'variables', ]), - Page::create('variables', 'basics/variables.md', [ + Page::create('variables', 'basics/02-variables.md', [ 'title' => 'Variables', 'subtitle' => 'The building blocks of PHP', 'previous' => 'basics', 'next' => 'arithmetic', ]), - Page::create('arithmetic', 'basics/arithmetic.md', [ + Page::create('arithmetic', 'basics/03-arithmetic.md', [ 'title' => 'Arithmetic', 'subtitle' => 'Doing math like a pro', 'previous' => 'variables', 'next' => 'strings', ]), - Page::create('strings', 'basics/strings.md', [ + Page::create('strings', 'basics/04-strings.md', [ 'title' => 'Strings', 'subtitle' => 'Working with text', 'previous' => 'arithmetic', 'next' => 'comparisons', ]), - Page::create('comparisons', 'basics/comparisons.md', [ + Page::create('comparisons', 'basics/05-comparisons.md', [ 'title' => 'Comparisons', 'subtitle' => 'Equality checking', 'previous' => 'strings', 'next' => 'boolean-logic', ]), - Page::create('boolean-logic', 'basics/boolean-logic.md', [ + Page::create('boolean-logic', 'basics/06-boolean-logic.md', [ 'title' => 'Boolean Logic', 'subtitle' => 'Is it a yes or a no?', 'previous' => 'comparisons', 'next' => 'conditionals', ]), - Page::create('conditionals', 'basics/conditionals.md', [ + Page::create('conditionals', 'basics/07-conditionals.md', [ 'title' => 'Conditionals', 'subtitle' => 'Checking the if before the what', 'previous' => 'boolean-logic', 'next' => 'loops', ]), - Page::create('loops', 'basics/loops.md', [ + Page::create('loops', 'basics/08-loops.md', [ 'title' => 'Loops', 'subtitle' => 'Increase your repetitions', 'previous' => 'conditionals', 'next' => 'arrays', ]), - Page::create('arrays', 'basics/arrays.md', [ + Page::create('arrays', 'basics/09-arrays.md', [ 'title' => 'Arrays', 'subtitle' => 'Time to make a list', 'previous' => 'loops', 'next' => 'functions', ]), - Page::create('functions', 'basics/functions.md', [ + Page::create('functions', 'basics/10-functions.md', [ 'title' => 'Functions', 'subtitle' => 'Reusable code', 'previous' => 'arrays', 'next' => 'classes', ]), - Page::create('classes', 'basics/classes.md', [ + Page::create('classes', 'basics/11-classes.md', [ 'title' => 'Classes', 'subtitle' => 'Object-oriented programming', 'previous' => 'functions', 'next' => 'classes-inheritance', ]), - Page::create('classes-inheritance', 'basics/classes-inheritance.md', [ + Page::create('classes-inheritance', 'basics/12-classes-inheritance.md', [ 'title' => 'Classes: Inheritance', 'subtitle' => 'Extend your objects', 'previous' => 'classes', 'next' => 'classes-visibility', ]), - Page::create('classes-visibility', 'basics/classes-visibility.md', [ + Page::create('classes-visibility', 'basics/13-classes-visibility.md', [ 'title' => 'Classes: Visibility', 'subtitle' => 'Privatizing your objects', 'previous' => 'classes-inheritance', 'next' => 'classes-constructor', ]), - Page::create('classes-constructor', 'basics/classes-constructor.md', [ + Page::create('classes-constructor', 'basics/14-classes-constructor.md', [ 'title' => 'Classes: Constructor', 'subtitle' => 'Construct your objects', 'previous' => 'classes-visibility', 'next' => 'static', ]), - Page::create('static', 'basics/static.md', [ + Page::create('static', 'basics/15-static.md', [ 'title' => 'Static', 'subtitle' => 'Class properties and methods', 'previous' => 'classes-constructor', 'next' => 'interfaces', ]), - Page::create('interfaces', 'basics/interfaces.md', [ + Page::create('interfaces', 'basics/16-interfaces.md', [ 'title' => 'Interfaces', 'subtitle' => 'Writing code contracts', 'previous' => 'static', 'next' => 'abstract', ]), - Page::create('abstract', 'basics/abstract.md', [ + Page::create('abstract', 'basics/17-abstract.md', [ 'title' => 'Abstract Classes', 'subtitle' => 'Inheriting an interface', 'previous' => 'interfaces', 'next' => 'exceptions', ]), - Page::create('exceptions', 'basics/exceptions.md', [ + Page::create('exceptions', 'basics/18-exceptions.md', [ 'title' => 'Exceptions', 'subtitle' => 'Throwing errors', 'previous' => 'abstract', From b8b7376deb162ef19cb65765f1365bc44a2e2592 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Sat, 12 Jan 2019 15:41:00 -0600 Subject: [PATCH 3/3] Fixing testing stub for page changes --- test/static/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/static/config.php b/test/static/config.php index 5b3ff74..8f582e0 100644 --- a/test/static/config.php +++ b/test/static/config.php @@ -9,8 +9,8 @@ return [ 'output_dir' => '/tmp/apprentice_output', 'files_dir' => __DIR__ . '/files', 'pages' => [ - Page::create('index', 'index.phtml'), - Page::create('test', null, 'test.md', [ + Page::create('index', null, [], 'index.phtml'), + Page::create('test', 'test.md', [ 'title' => 'Test Title', 'subtitle' => 'Test Subtitle', 'description' => 'Test Description',