Skip to content

Merge 2.1 in master #339

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

Merged
merged 15 commits into from
Nov 10, 2017
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
10 changes: 3 additions & 7 deletions admin/authentication-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Authentication can easily be handled when using the API Platform's admin library.
In the following section, we will assume [the API is secured using JWT](https://api-platform.com/docs/core/jwt), but the
process is similar for other authentication mechanisms. The `login_uri` is the full URI to the route specified by the `firewalls.login.json_login.check_path` config in the [JWT documentation](https://api-platform.com/docs/core/jwt).
process is similar for other authentication mechanisms. The `login_uri` is the full URI to the route specified by the `firewalls.login.json_login.check_path` config in the [JWT documentation](https://api-platform.com/docs/core/jwt).

The first step is to create a client to handle the authentication process:

Expand All @@ -11,7 +11,7 @@ The first step is to create a client to handle the authentication process:
import { AUTH_LOGIN, AUTH_LOGOUT, AUTH_ERROR, AUTH_CHECK } from 'admin-on-rest';

// Change this to be your own login check route.
const login_uri = 'https://demo.api-platform.com/login_check';
const login_uri = 'https://demo.api-platform.com/login_check';

export default (type, params) => {
switch (type) {
Expand Down Expand Up @@ -48,7 +48,7 @@ export default (type, params) => {

case AUTH_CHECK:
return localStorage.getItem('token') ? Promise.resolve() : Promise.reject();

default:
return Promise.resolve();
}
Expand Down Expand Up @@ -105,7 +105,3 @@ export default props => (

Refer to [the chapter dedicated to authentication in the Admin On Rest documentation](https://marmelab.com/admin-on-rest/Authentication.html)
for more information.

Previous chapter: [Getting Started](getting-started.md)

Next chapter: [Handling Relations to Collections](handling-relations-to-collections.md)
8 changes: 2 additions & 6 deletions admin/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Then, create a new React application for your admin:
$ create-react-app my-admin

React and React DOM will be directly provided as dependencies of Admin On REST. As having different versions of React
causes issues, remove `react` and `react-dom` from the `dependencies` section of the generated `package.json` file:
causes issues, remove `react` and `react-dom` from the `dependencies` section of the generated `package.json` file:

```patch
- "react": "^15.6.1",
Expand Down Expand Up @@ -153,7 +153,7 @@ export default (props) => <HydraAdmin apiDocumentationParser={apiDocumentationPa
__Note__: In this example, we choose to send the file via a multi-part form data, but you are totally free to use another solution (like `base64`). But keep in mind that multi-part form data is the most efficient solution.

### Using a Custom Validation Function or Inject Custom Props

You can use `fieldProps` and `inputProps` to respectively inject custom properties to fields and inputs generated by API
Platform Admin. This is particularly useful to add custom validation rules:

Expand Down Expand Up @@ -186,7 +186,3 @@ export default class extends Component {
}
}
```

Previous chapter: [Introduction](index.md)

Next chapter: [Authentication Support](authentication-support.md)
7 changes: 2 additions & 5 deletions admin/handling-relations-to-collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This API can be created using the following PHP code:

```php
<?php
// src/AppBundle/Entity/Person.php

namespace App\Entity;

Expand Down Expand Up @@ -40,6 +41,7 @@ class Person

```php
<?php
// src/AppBundle/Entity/Book.php

namespace App\Entity;

Expand Down Expand Up @@ -128,7 +130,6 @@ Start by adding a "partial search" filter on the `name` property of the `Book` r

```yaml
# config/api_filters.yml

services:
person.search_filter:
parent: 'api_platform.doctrine.orm.search_filter'
Expand Down Expand Up @@ -168,7 +169,3 @@ Then edit the configuration of API Platform Admin to pass a `filterToQuery` prop
```

The autocomplete field should now work properly!

Previous chapter: [Authentication Support](authentication-support.md)

Next chapter: [Client Generator: Introduction](../client-generator/index.md)
4 changes: 0 additions & 4 deletions admin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,3 @@ You can also customize all screens by using Admin On Rest components and even ra
* Send proper HTTP requests to the API and decode them using Hydra and JSON-LD formats
* Nicely display server-side errors (e.g. advanced validation)
* **100% customizable**

Previous chapter: [Schema Generator: configuration](../schema-generator/configuration.md)

Next chapter: [Getting Started](getting-started.md)
4 changes: 0 additions & 4 deletions client-generator/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@ The generator works especially well with APIs built with the [API Platform](http
* The generated HTML is compatible with [Bootstrap](https://getbootstrap.com/) and includes mandatory classes
* The generated HTML code is accessible to people with disabilities ([ARIA](https://www.w3.org/WAI/intro/aria) support)
* The Redux and the React Router configuration is also generated

Previous chapter: [Admin: Handling Relations to Collections](../admin/handling-relations-to-collections.md)

Next chapter: [React generator](react.md)
9 changes: 2 additions & 7 deletions client-generator/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Bootstrap 3 - last release 0.1.15
```html
<!-- ... -->
<title>React App</title>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<!-- ... -->
Expand All @@ -29,14 +29,13 @@ Bootstrap 4 - from release 0.1.16
```html
<!-- ... -->
<title>React App</title>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>
<!-- ... -->
```


In the app directory, generate the files for the resource you want:

$ generate-api-platform-client https://demo.api-platform.com src/ --resource foo
Expand Down Expand Up @@ -82,7 +81,3 @@ ReactDom.render(

registerServiceWorker();
```

Previous chapter: [Introduction](index.md)

Next chapter: [Vue.js generator](vuejs.md)
46 changes: 21 additions & 25 deletions client-generator/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* The generator does not perform any authentication, so you must ensure that all referenced Hydra paths for your API are
accessible anonymously. If you are using API Platform this will at least include:

```
api_entrypoint ANY ANY ANY /{index}.{_format}
api_doc ANY ANY ANY /docs.{_format}
api_jsonld_context ANY ANY ANY /contexts/{shortName}.{_format}
```
```
api_entrypoint ANY ANY ANY /{index}.{_format}
api_doc ANY ANY ANY /docs.{_format}
api_jsonld_context ANY ANY ANY /contexts/{shortName}.{_format}
```

* If you receive `Error: The class http://www.w3.org/ns/hydra/core#ApiDocumentation doesn't exist.` you may have
specified the documentation URL instead of the entrypoint. For example if you are using API Platform and your
Expand All @@ -22,23 +22,19 @@ you are using by running something like `curl https://demo.api-platform.com/`.

* If you receive a message like this:

```
{ Error
at done (/usr/local/share/.config/yarn/global/node_modules/jsonld/js/jsonld.js:6851:19)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
name: 'jsonld.InvalidUrl',
message: 'Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object.',
details:
{ code: 'invalid remote context',
url: 'https://demo.api-platform.com/contexts/Entrypoint',
cause: null } }
```

Check access to the specified url, in this case `https://demo.api-platform.com/contexts/Entrypoint`, use curl to check
access and the response `curl https://demo.api-platform.com/contexts/Entrypoint`. In the above case an "Access Denied"
message in JSON format was being returned.

Previous chapter: [Vue.js generator](vuejs.md)

Next chapter: [Deployment: Introduction](../deployment/index.md)
```
{ Error
at done (/usr/local/share/.config/yarn/global/node_modules/jsonld/js/jsonld.js:6851:19)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
name: 'jsonld.InvalidUrl',
message: 'Dereferencing a URL did not result in a JSON object. The response was valid JSON, but it was not a JSON object.',
details:
{ code: 'invalid remote context',
url: 'https://demo.api-platform.com/contexts/Entrypoint',
cause: null } }
```

Check access to the specified url, in this case `https://demo.api-platform.com/contexts/Entrypoint`, use curl to check
access and the response `curl https://demo.api-platform.com/contexts/Entrypoint`. In the above case an "Access Denied"
message in JSON format was being returned.
5 changes: 1 addition & 4 deletions client-generator/vuejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Create a Vue.js application using [vue-cli](https://github.com/vuejs/vue-cli):

Install Vue Router, Vuex and babel-plugin-transform-builtin-extend (to allow extending bultin types like Error and Array):

$ yarn add vue-router vuex babel-plugin-transform-builtin-extend babel-preset-es2015 babel-preset-stage-2
$ yarn add vue-router vuex babel-plugin-transform-builtin-extend babel-preset-es2015 babel-preset-stage-2

Install the generator globally:

Expand Down Expand Up @@ -100,6 +100,3 @@ Replace the `App.vue` file with the following :
</div>
</template>
```
Previous chapter: [React generator](react.md)

Next chapter: [Troubleshooting](troubleshooting.md)
11 changes: 5 additions & 6 deletions core/angularjs-integration.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# AngularJS integration
# AngularJS Integration

Warning: For new project, you should consider using [the API Platform's Progressive Web App generator](../client-generator/index.md)
(that supports React and Vue.js) instead of this Angular v1 integration.

## Restangular

ApiPlatformBundle works fine with [AngularJS v1](http://angularjs.org). The popular [Restangular](https://github.com/mgonto/restangular)
API Platform works fine with [AngularJS v1](http://angularjs.org). The popular [Restangular](https://github.com/mgonto/restangular)
REST client library for Angular can easily be configured to handle the API format.

Here is a working Restangular config:
Expand Down Expand Up @@ -95,7 +98,3 @@ nga.configure(admin);
```

You can look at what we have done as another exemple [api-platform/admin](https://github.com/api-platform/admin).

Previous chapter: [NelmioApiDocBundle integration](nelmio-api-doc.md)

Next chapter: [Swagger Support](swagger.md)
5 changes: 0 additions & 5 deletions core/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Here's the complete configuration of the Symfony bundle with including default v

```yaml
# app/config/config.yml

api_platform:

# The title of the API.
Expand Down Expand Up @@ -188,7 +187,3 @@ api_platform:

# ...
```

Previous chapter: [Getting Started](getting-started.md)

Next chapter: [Operations](operations.md)
12 changes: 1 addition & 11 deletions core/content-negotiation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ and of a custom format called `myformat` and having `application/vnd.myformat` a

```yaml
# app/config/config.yml

api_platform:

# ...

formats:
Expand Down Expand Up @@ -79,9 +77,7 @@ own implementation of `CustomItemNormalizer`:

```yaml
# app/config/services.yml

services:

# ...

'AppBundle\Serializer\CustomItemNormalizer':
Expand All @@ -91,7 +87,6 @@ services:

```php
<?php

// src/AppBundle/Serializer/CustomItemNormalizer.php

namespace AppBundle\Serializer;
Expand Down Expand Up @@ -139,7 +134,6 @@ flatten or remove too complex relations:

```php
<?php

// src/AppBundle/Serializer/CustomItemNormalizer.php

namespace AppBundle\Serializer;
Expand Down Expand Up @@ -167,11 +161,7 @@ class CustomItemNormalizer implements NormalizerInterface, DenormalizerInterface

return $result;
}

// ...
}
```

Previous chapter: [The Event System](events.md)

Next chapter: [Using External JSON-LD Vocabularies](external-vocabularies.md)
12 changes: 3 additions & 9 deletions core/data-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Both implementations can also implement a third, optional interface called
if you want to limit their effects to a single resource or operation.

In the following examples we will create custom data providers for an entity class called `AppBundle\Entity\BlogPost`.
Note, that if your entity is not Doctrine-related, you need to flag the identifier property by using `@ApiProperty(identifier=true)` for things to work properly (see also [Entity Identifier Case](serialization-groups-and-relations.md#entity-identifier-case)).
Note, that if your entity is not Doctrine-related, you need to flag the identifier property by using `@ApiProperty(identifier=true)` for things to work properly (see also [Entity Identifier Case](serialization.md#entity-identifier-case)).

## Custom Collection Data Provider

Expand All @@ -33,7 +33,6 @@ If no data is available, you should return an empty array.

```php
<?php

// src/AppBundle/DataProvider/BlogPostCollectionDataProvider.php

namespace AppBundle\DataProvider;
Expand Down Expand Up @@ -83,7 +82,6 @@ The `getItem` method can return `null` if no result has been found.

```php
<?php

// src/AppBundle/DataProvider/BlogPostItemDataProvider.php

namespace AppBundle\DataProvider;
Expand All @@ -110,8 +108,8 @@ final class BlogPostItemDataProvider implements ItemDataProviderInterface, Restr

If service autowiring and autoconfiguration are enabled (it's the case by default), you are done!

Otherwise, if you use a custom dependency injection configuration, you need to register the corresponding service add the
`api_platform.item_data_provider` tag. As for collection data providers, the `priority` attribute can be used to order
Otherwise, if you use a custom dependency injection configuration, you need to register the corresponding service and add the
`api_platform.item_data_provider` tag to it. As for collection data providers, the `priority` attribute can be used to order
providers.

```yaml
Expand Down Expand Up @@ -163,7 +161,3 @@ final class BlogPostItemDataProvider implements ItemDataProviderInterface, Seria
}
}
```

Previous chapter: [Extending JSON-LD context](extending-jsonld-context.md)

Next chapter: [Extensions](extensions.md)
9 changes: 2 additions & 7 deletions core/default-order.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ customize this order, you must add an `order` attribute on your ApiResource anno

```php
<?php

// src/AppBundle/Entity/Book.php

namespace AppBundle\Entity;
Expand All @@ -33,7 +32,6 @@ If you only specify the key, `ASC` direction will be used as default. For exampl

```php
<?php

// src/AppBundle/Entity/Book.php

namespace AppBundle\Entity;
Expand Down Expand Up @@ -61,8 +59,8 @@ class Book

It's also possible to configure the default filter on an association property:

```php
<?php

// src/AppBundle/Entity/Book.php

namespace AppBundle\Entity;
Expand All @@ -81,7 +79,4 @@ class Book
*/
public $author;
}

Previous chapter: [Operations](operations.md)

Next chapter: [Filters](filters.md)
```
5 changes: 0 additions & 5 deletions core/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ In the following example, we will send a mail each time a new book is created us

```php
<?php

// src/AppBundle/EventSubscriber/BookMailSubscriber.php

namespace AppBundle\EventSubscriber;
Expand Down Expand Up @@ -105,7 +104,3 @@ Constant | Event | Priority |
`POST_WRITE` | `kernel.view` | 31 |
`PRE_RESPOND` | `kernel.view` | 9 |
`POST_RESPOND` | `kernel.response` | 0 |

Previous chapter: [Pagination](pagination.md)

Next chapter: [Content Negotiation](content-negotiation.md)
Loading