Skip to content

Commit

Permalink
Docs updates for framework
Browse files Browse the repository at this point in the history
  • Loading branch information
darylldoyle committed Jan 30, 2025
1 parent dbe1de2 commit bfcd6ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/creating-post-types-and-taxonomies.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ If you want to jump right in, take a look at the `TenUpPlugin\PostTypes\Demo::cl

## Post Types

To create a new post type, you will need to create a new class that extends the `TenUpPlugin\PostTypes\AbstractPostType` class. This class will contain the configuration for the new post type.
To create a new post type, you will need to create a new class that extends the `TenupFramework\PostTypes\AbstractPostType` class. This class will contain the configuration for the new post type.

Once you've extended the class (or copied the `Demo` class), you will need to define the following methods:

Expand Down Expand Up @@ -171,7 +171,7 @@ The `after_register()` method can also be useful to hook into anything else you

## Taxonomies

To create a new taxonomy, you will need to create a new class that extends the `TenUpPlugin\Taxonomies\AbstractTaxonomy` class. This class will contain the configuration for the new taxonomy.
To create a new taxonomy, you will need to create a new class that extends the `TenupFramework\Taxonomies\AbstractTaxonomy` class. This class will contain the configuration for the new taxonomy.

Once you've extended the class (or copied the `Demo` class), you will need to define the following methods:

Expand Down
32 changes: 13 additions & 19 deletions docs/registering-classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To do this, it uses the [haydenpierce/class-finder](https://packagist.org/packag

## How do I define a class to be auto-registered?

All you need to do to get a class to auto-register is extend the `TenUpPlugin\Module::class` or `TenUpTheme\Module::class` classes. That will require you to implement a `can_register()` and a `register()` method.
All you need to do to get a class to auto-register is implement the `TenupFramework\ModuleInterface` interface and use the `TenupFramework\Module` trait. Finally, you will need to implement a `can_register()` and a `register()` method.

### `can_register()`

Expand Down Expand Up @@ -68,7 +68,9 @@ namespace TenUpPlugin\Admin;
/**
* Provide a Site Settings screen.
*/
class SiteSettings extends \TenUpPlugin\Module {
class SiteSettings implements \TenupFramework\ModuleInterface {

use \TenupFramework\Module;

/**
* Fieldmanager Setting ID
Expand Down Expand Up @@ -166,11 +168,13 @@ namespace TenUpPlugin\Admin;
/**
* Taxonomy Factory
*/
class TaxonomyFactory extends \TenUpPlugin\Module {
class TaxonomyFactory implements \TenupFramework\ModuleInterface {

use \TenupFramework\Module;

public $load_order = 9;
public $load_order = 9;

// Rest of class removed for brevity.
// Rest of class removed for brevity.
}
```

Expand All @@ -180,24 +184,14 @@ namespace TenUpPlugin\Admin;
/**
* Post Type Factory
*/
class PostTypeFactory extends \TenUpPlugin\Module {
class PostTypeFactory implements \TenupFramework\ModuleInterface {

use \TenupFramework\Module;

// Rest of class removed for brevity.
// Rest of class removed for brevity.
}
```

We've defined two classes, one using the default load order (`10`) and another with a custom load order (`9`).

Because of this, the `TaxonomyFactory` class will always be loaded before the `PostTypeFactory` class.

## Known Issues

### Could not locate `composer.json`

During deployment, we must deploy the `composer.json` file. This is how the class finder works, so if it doesn't exist you'll get an exception that states:

```
Could not locate composer.json. You can get around this by setting ClassFinder::$appRoot manually.
```

More information on this issue is available [here](https://gitlab.com/hpierce1102/ClassFinder/-/blob/master/docs/exceptions/missingComposerConfig.md).

0 comments on commit bfcd6ee

Please sign in to comment.